content-type to be used for uploading svg images to AWS S3
For those using an SDK, here's an example code snippet that I used to solve this problem. Im using Javascript (NodeJs). This is to complement the accepted answer above, which is to explicitly define the ContentType as 'image/svg+xml' from the params before uploading.
const params = {
Bucket: 'bucket',
Key: 'key',
Body: stream,
ACL: 'public-read',
ContentType: 'image/svg+xml',
};
s3.upload(params, function(err, data) {
console.log(err, data);
});
As you mentioned, the correct Content-Type for SVG files is "image/svg+xml".
Even if the AWS console does not provide that value in the Content-Type selection field, you can enter it anyway and S3 will accept it.
AWS specifies the following in their API docs for the Content-Type header:
A standard MIME type describing the format of the contents. For more information, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17.
Type: String
Default: binary/octet-stream
Valid Values: MIME types
Constraints: None
For additional details see http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html