aws-sdk-java
aws-sdk-java copied to clipboard
Multipart file upload content type
It looks like the normal putObject
method on the S3 client will add a content-type header for you if one is missing. This is super helpful and I couldn't see this behaviour in the initiateMultipartUpload
method. All the files I've uploaded end up having the content-type set to application/octet-stream
I'm currently using the AmazonS3 interface via the https://github.com/spring-cloud/spring-cloud-aws project and it's not possible to set the ObjectMetadata there.
Would it be possible to add this functionality to the initiateMultipartUpload
method, as I can see the rest api supports that header?
Hey i found some work arounds for this, you can either call the s3 rest api directly which will work properly, or you can provide the content type when you initiate the multipart upload
eg:
//setting object metadata to have your file content type
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentType("video/mp4");
// Initiate the multipart upload.
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(
bucket,
key,
objectMetadata
);
code to uploadPart and also to complete remains the same
@pacey @rafael-adcp
Just a quick update letting you know that the SDK team has reviewed the feature request list for V1 and this looks like a great candidate for a community PR, which we’ll help merge in and support.
I can have a stab at it @debora-ito
I would like help in contributing for this issue. Please message me if you have any questions. I can begin working on it.