Content-Type header in GetObject from S3

0

I have used the GetObject with Authorisation header; and a GET in the browser with a pre-signed url.

The content is returned but the Content-Type header shows 'junk'. The screen shot is attached .. I get the same value with GetObject and GET in the browser.

Thanks K Enter image description here

asked a year ago2156 views
1 Answer
0

When uploading an object to Amazon S3 you can specify a string as the Content-Type for an object. If a string is specified in the Content-Type, that value would override any guessed mime types by Amazon S3. It appears that when the object was uploaded to the bucket and random string of characters was added as the Content-Type for the object.

You can test this out by performing a HeadObject API call on the object via AWS CLI. You should find that the response contains the same Content-Type that you are seeing in your browser.

To correct this behavior, you should re-upload the object to the bucket without specifying any Content-Type in the PutObject request. Once uploaded, you can double-check the Content-Type by performing a HeadObject request. If you continue to receive this same behavior, you can try to specify manually specify the Content-Type for the object in the PutObject request. However, Amazon S3 follows RFC 9110 when it comes to the Content-Type header and should be able add a Content-Type that is not a random string of characters.

https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html#API_PutObject_RequestSyntax https://www.rfc-editor.org/rfc/rfc9110.html#name-content-type

profile pictureAWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions