google-app-enginesvgmime-types

Google App Engine is sending SVG with wrong mime-type


I'm using Google App Engine with Python 2.7 and I'm trying to use an svg-file as a sprite-sheet.

For some reason this works fine on Win7 and Ubuntu, but not on Vista or Mac (Using the latest Chrome and Firefox in each case).

Here it's sent with mime-type "application/octet-stream" and the browsers prompts to download it, instead of displaying it.

I tried overriding the mime-type in my app.yaml like this:

- url: /img/.*\.svg
  static_dir: public/img
  mime_type: image/svg+xml

- url: /img
  static_dir: public/img

But that didn't change anything.

I also tried to route requests for svg-files through their own url like this

- url: /img/svg
  static_dir: public/img
  mime_type: image/svg+xml

- url: /img
  static_dir: public/img

But that results in the file being sent with mime-type "img/png", so the browser will at least try to display it, but can't.

Just to make sure, I tried each combination as stated and also with the headers-options:

- url: /img/svg
  static_dir: public/img
  http_headers:
    mime-type: image/svg+xml

Without success.

Any help please?

[edit]

After some more testing, it seems like on Ubuntu using the local app-launcher, it sends the svg as text/html and when deployed it uses application/octet-stream, regardless of what I put in the app.yaml.

Does anybody have experience with this? The only way I can solve this is to insert the svg-code into the page directly, which kinda sucks. It's a graphic and I want to treat it that way.

[more edit]

In the end, I put this in the yaml-file and it seems to work:

- url: /img/.*\.svg
  static_dir: public/img
  http_headers:
    content_type: image/svg+xml

- url: /img
  static_dir: public/img

Solution

  • Try:

    http_headers:
      content-type: image/svg+xml