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

preguntada hace un año2258 visualizaciones
1 Respuesta
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
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas