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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With