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

已提問 1 年前檢視次數 2218 次
1 個回答
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
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南