Engine发送的MIME类型错误的SVG

Engine发送的MIME类型错误的SVG

本文介绍了Google App Engine发送的MIME类型错误的SVG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Google App Engine与Python 2.7结合使用,并且尝试使用svg文件作为Sprite-sheet.

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

由于某种原因,它在Win7和Ubuntu上可以正常工作,但在Vista或Mac上却不能(在每种情况下都使用最新的Chrome和Firefox).

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).

此处以mime类型的"application/octet-stream"发送,浏览器提示下载而不是显示.

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

我试图像这样在我的app.yaml中覆盖mime类型:

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.

我也试图通过这样的网址将svg文件的请求路由

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

但这会导致文件以mime类型的"img/png"发送,因此浏览器至少会尝试显示它,但不能显示.

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.

为了确保确定,我按照说明尝试了每种组合,还尝试了headers-options:

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

没有成功.

请帮忙吗?

经过更多测试后,似乎在Ubuntu上使用本地应用程序启动程序,它将svg发送为text/html,并且在部署时使用application/octet-stream发送,无论我将app.yaml放在什么位置.

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.

有人对此有经验吗?我可以解决此问题的唯一方法是将svg代码直接插入页面,这有点糟.这是一个图形,我想这样处理.

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.

[更多编辑]

最后,我将其放在yaml文件中,它似乎可以正常工作:

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

推荐答案

尝试:

http_headers:
  content-type: image/svg+xml

这篇关于Google App Engine发送的MIME类型错误的SVG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 04:43