aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

Multipart file upload content type

Open pacey opened this issue 6 years ago • 4 comments

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?

pacey avatar Jun 25 '18 13:06 pacey

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

rafael-adcp avatar Jun 06 '19 20:06 rafael-adcp

@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.

debora-ito avatar Sep 05 '19 23:09 debora-ito

I can have a stab at it @debora-ito

pacey avatar Sep 06 '19 10:09 pacey

I would like help in contributing for this issue. Please message me if you have any questions. I can begin working on it.

JasonVoss avatar Oct 29 '21 17:10 JasonVoss