Answers.Body: <p>On old versions of python, the python library mimetypes didnt have a definition for svg file types. </p>
  
  <p>See this issue: <a href="https://bugs.python.org/issue19377" rel="nofollow noreferrer">https://bugs.python.org/issue19377</a></p>
  
  <p>I added <code>'.svg' : 'image/svg+xml',</code> into the <code>types_map</code> in <code>mimetypes.py</code> and then the aws cli got the correct type for SVGs.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-25T17:56:47.963Z
Answers.LastActivityDate: 2019-02-25T17:56:47.963Z
Answers.UserDisplayName: scottarver
Answers.Body: <p>Your SVG file is probably missing the the XML declaration at the top (<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code>). PHP's FileInfo detects XML files (which SVG is) without that declaration as text/html files.</p>
  
  <p>Lots of SVG editors/exporters will (annoyingly) omit that.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-15T23:39:13.910Z
Answers.Text: Aha! That fixed it. I wonder why PHP doesn't rely on the extension rather than some optional doc type definition.
  
  Anyway, *shakes fist @ Adobe Illustrator team*.
Answers.UserDisplayName: mrtobo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-15T23:53:58.743Z
Answers.Text: Probably because extensions can lie. :)  `mv img.jpg img.svg`
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-16T15:57:19.990Z
Answers.Text: That seems fair, but still it a much more difficult mistake to make than your SVG editor silently omitting an arcane xml node. ¯\_(ツ)_/¯
Answers.UserDisplayName: mrtobo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-16T17:48:16.087Z
Answers.Text: Not so much a mistake, but could be used to exploit servers potentially.  i.e. if you restrict uploads based only on file extensions, but then rename `mybadscript.exe` to `cutekitten.jpg`, you've delivered a payload and now just need to find a way to execute it.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-17T11:39:36.147Z
Answers.Text: it is working for me. It really great solutions
Answers.UserDisplayName: Anwar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-15T23:20:56.290Z
Answers.LastActivityDate: 2016-11-15T23:20:56.290Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've setup an S3 asset source for images and it's working well for everything but SVGs.</p>
  
  <p>SVGs are uploaded with the default content-type of <code>binary/octet-stream</code> where the correct content-type would be <code>image/svg+xml</code>.</p>
  
  <p>Am I doing something wrong or is this a bug?</p>
  
Tags: <assets><s3>
Title: Incorrect content/mime-type on S3 SVG upload
ThreadText: # Incorrect content/mime-type on S3 SVG upload
  
  (Asked by: username_0 on 2016-11-15)
  
  I've setup an S3 asset source for images and it's working well for everything but SVGs.
  
  SVGs are uploaded with the default content-type of `binary/octet-stream` where the correct content-type would be `image/svg+xml`.
  
  Am I doing something wrong or is this a bug?
  
  **Tags:** assets, s3
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-11-15. Score: 5 | Accepted answer
  
  Your SVG file is probably missing the the XML declaration at the top (`<?xml version="1.0" encoding="UTF-8"?>`). PHP's FileInfo detects XML files (which SVG is) without that declaration as text/html files.
  
  Lots of SVG editors/exporters will (annoyingly) omit that.
  
  > **Comments:**
  > **username_0**: Aha! That fixed it. I wonder why PHP doesn't rely on the extension rather than some optional doc type definition.  Anyway, *shakes fist @ Adobe Illustrator team*.  
  > **username_2**: Probably because extensions can lie. :)  `mv img.jpg img.svg`  
  > **username_0**: That seems fair, but still it a much more difficult mistake to make than your SVG editor silently omitting an arcane xml node. ¯\_(ツ)_/¯  
  > **username_2**: Not so much a mistake, but could be used to exploit servers potentially.  i.e. if you restrict uploads based only on file extensions, but then rename `mybadscript.exe` to `cutekitten.jpg`, you've delivered a payload and now just need to find a way to execute it.  
  > **username_3**: it is working for me. It really great solutions  
  
  ---
  
  ### Answer by username_1 on 2019-02-25. Score: -1
  
  On old versions of python, the python library mimetypes didnt have a definition for svg file types.
  
  See this issue: <https://bugs.python.org/issue19377>
  
  I added `'.svg' : 'image/svg+xml',` into the `types_map` in `mimetypes.py` and then the aws cli got the correct type for SVGs.
  
  
  ---
  
  