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

demandé il y a un an2219 vues
1 réponse
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
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions