Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

content-type to be used for uploading svg images to AWS S3

I was trying to upload *.svg images to S3 without specifying any Content-type. This upload works successfully and AWS sets Content-Type as binary/octet-stream by default. Now, when I try to use S3 url of image in my browser, the browser does not render the image and throws incorrect mime-type warning.

To set the correct mime-type I checked list of Content-type which AWS offers but it does not have "image/svg+xml".

So I wanted to know if anyone has tried to upload svg images to S3? What is the content-type set in that case? Or is there any other compatible Content-type that can be used for uploading svg images to S3?

Thanks in Advance.

like image 216
UW20989 Avatar asked Aug 02 '13 05:08

UW20989


People also ask

What type of image is stored in an SVG file?

What is an SVG file? Scalable Vector Graphics (SVG) is a web-friendly vector file format. As opposed to pixel-based raster files like JPEGs, vector files store images via mathematical formulas based on points and lines on a grid.

How do I upload images to Amazon S3?

jpg . Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to upload your folders or files to. Choose Upload.

What is image SVG XML?

SVG is a language for describing two-dimensional graphics in XML [XML10]. SVG allows for three types of graphic objects: vector graphic shapes (e.g., paths consisting of straight lines and curves), images and text. Graphical objects can be grouped, styled, transformed and composited into previously rendered objects.

What is SVG upload?

An SVG (scalable vector graphics) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium (W3C) since 1999. You can even manipulate SVG files with code or your text editor.


1 Answers

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

like image 166
dcro Avatar answered Sep 17 '22 15:09

dcro