Here we go:
[1]
http://pastie.org/7634614 (further to [s1])
--> Metadata shows Content-Type=image/jpeg
[2]
http://pastie.org/7634665 (further to [s2])
--> Metadata shows Content-Type=application/unknown
Seems like [2] does not send the AccessControlPolicy (XML) and misses a
final step present in [1].
Thx, Eric
[s1]
BlobStoreContext context = ContextBuilder. //
newBuilder("aws-s3"). //
credentials(IDENTITY, CREDENTIALS). //
modules(ImmutableSet.<Module> of(
new Log4JLoggingModule())). //
buildView(BlobStoreContext.class);
BlobStore store = context.getBlobStore();
Blob blob = store.blobBuilder(BUCKET_NAME). //
name(IMAGE_NAME). //
payload(new File("src/main/resources/" + IMAGE_NAME)). //
// or byte[], InputStream...
contentDisposition("attachment; filename=" +
IMAGE_NAME). //
contentType("image/jpeg"). //
calculateMD5(). //
build();
store.putBlob(BUCKET_NAME, blob);
AWSS3Client s3Client = ContextBuilder. //
newBuilder("aws-s3"). //
credentials(IDENTITY, CREDENTIALS). //
modules(ImmutableSet.<Module> of(
new Log4JLoggingModule())). //
buildApi(AWSS3Client.class);
S3Object s3Object = s3Client.newS3Object();
s3Object.getMetadata().setKey(IMAGE_NAME);
s3Object.getMetadata().getContentMetadata().setContentType("image/jpeg");
s3Object.setPayload(new File("src/main/resources/" + IMAGE_NAME));
s3Client.putObject(BUCKET_NAME, s3Object,
withAcl(CannedAccessPolicy.PUBLIC_READ));
s3Client.close();