- 18 Dec 2023
- 2 Minutes to read
- Print
- PDF
How can I change the MIME/Content-Type associated with my objects stored in Wasabi?
- Updated on 18 Dec 2023
- 2 Minutes to read
- Print
- PDF
The MIME type of your object determines how a browser interacts with your object when it is requested for download. For example, if you have an image hosted on Wasabi that you wish to have displayed in a browser when the link is clicked, the MIME type value must accurately depict that this is an image in order for the browser to know how to display it to the client. Using the example of an image (let's say a PNG file), if your object has a MIME type set of image/png
then the browser will know this is an image and will display it as such. However, if your object's MIME type is set as application/octet-stream
, then the browser will assume this is an application and will prompt the client to download the object instead of displaying the object.
Here is a list of common MIME types found on the web: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
The MIME type will be set on the object during the PUT operation to the bucket. If using the Wasabi Console, it will generally understand that an image should have the appropriate values in order to be displayed properly when requested. However, depending on your PUT method, this value may not always be set correctly.
This value can be changed via an API call to your Wasabi bucket and the key/value that you would like to have changed. The API call needed would be the PutObject call with the URI Request Parameter of Content-Type and the value you wish to have associated with it. An easy way to achieve this is via AWS CLI (How do I use AWS CLI with Wasabi?).
For example, I uploaded a picture to my bucket 'virginia' and set the MIME/content-type to 'binary/octet-stream':
$ aws s3api head-object --bucket virginia --key picture.jpg --endpoint-url=https://s3.wasabisys.com
{
"AcceptRanges": "bytes",
"LastModified": "2021-02-15T18:06:03+00:00",
"ContentLength": 0,
"ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
"ContentType": "binary/octet-stream",
"Metadata": {}
}
You can change this to your desired value via the put-object
call with the --content-type
flag:
$ aws s3api put-object --bucket virginia --key picture.jpg --body picture.jpg --content-type=image/jpeg --endpoint-url=https://s3.wasabisys.com
{
"ETag": "\"d41d8cd98f00b204e9800998ecf8427e\""
}
Which then shows us the new MIME/Content-Type value here:
$ aws s3api head-object --bucket virginia --key picture.jpg --endpoint-url=https://s3.wasabisys.com
{
"AcceptRanges": "bytes",
"LastModified": "2021-02-15T18:06:51+00:00",
"ContentLength": 0,
"ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
"ContentType": "image/jpeg",
"Metadata": {}
}
Simply modify the above put-object
command to work with your environment (bucket/key/content-type/endpoint) and they should then be displaying properly.
If you have any questions about this setting and you are having difficulty changing it on your end, please reach out to Wasabi Support at support@wasabi.com so we can assist further.