Hi,
You are not really required to set the object's bucket variable before calling S3Service#putObject, because this method only pays attention to the bucket provided as a variable.
The default constructors for S3Object require the bucket be provided to encourage users to provide as much information as possible, and to reduce the chance that subsequent S3Object#getBucketName calls will return null. However, as you point out this leads to some doubling-up. If you would prefer to avoid the doubling-up you can provide a null Bucket value when you construct the S3Object, or build up the object's contents manually like so:
S3Object object = new S3Object(key);
ByteArrayInputStream bais = new ByteArrayInputStream(
dataString.getBytes(Constants.DEFAULT_ENCODING));
object.setDataInputStream(bais);
object.setContentLength(bais.available());
object.setContentType("text/plain; charset=utf-8");
Cheers,
James
On Fri, May 23, 2008 at 1:38 AM, Pulp Mystery Fan <
max@...> wrote:
I'm not sure I'm using these classes correctly. I'm creating an S3Object
using the three argument constructor, which includes a reference to the
bucket. If guess I'm supposed to post the data using S3Service.#putObject(),
which also takes a reference to the bucket. Why do I have to specify the
bucket twice? Thanks! :)
S3Object o = new S3Object(bucket, key, string);
getS3Service().putObject(bucket, o); // Why do I need to specify the bucket
again?
--
View this message in context: http://www.nabble.com/Newbie-question%3A-Why-repeat-bucket-in-S3Service-putObject%28%29--tp17407010p17407010.html
Sent from the JetS3t Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...
--
http://www.jamesmurty.com