无法猜出mimetype

时间:2013-12-06 13:40:01

标签: google-app-engine go

在测试服务器goapp serv上工作,在appengine上它会被application / octet-stream覆盖。

我如何告诉appengine停止这样做?

Could not guess mimetype for home/fonts/FontAwesome.otf. Using application/octet-stream...

我的配置文件:

application: test
version: 0
runtime: go
api_version: go1
threadsafe: true

handlers:
 - url: /home
   static_dir: home

 - url: /home/font/(.*\.woff)
   static_files: home/font/\1
   upload: home/font/(.*\.woff)
   http_headers:
    Content-Type: application/font-woff

 - url: /home/font/(.*\.svg)
   static_files: home/font/\1
   upload: home/font/(.*\.svg)
   http_headers:
    Content-Type: image/svg+xml

 - url: /home/font/(.*\.eot)
   static_files: home/font/\1
   upload: home/font/(.*\.eot)
   http_headers:
    Content-Type: application/vnd.ms-fontobject

 - url: /home/font/(.*\.ttf)
   static_files: home/font/\1
   upload: home/font/(.*\.ttf)
   http_headers:
    Content-Type: application/x-font-ttf

 - url: /home/font/(.*\.otf)
   static_files: home/font/\1
   upload: home/font/(.*\.otf)
   http_headers:
    Content-Type: application/x-font-otf

 - url: /favicon.ico
   static_files: home/favicon.ico
   upload: home/favicon.ico

 - url: /documentation
   static_dir: documentation

 - url: /.*
   script: _go_app

inbound_services:
 - warmup

2 个答案:

答案 0 :(得分:25)

我相信它在本地工作的原因是你的系统具有为/etc/mime.types中的.otf扩展名定义的所需mime类型或等效。

AppEngine可能没有。因此,您必须提供有关正确MIME类型的提示。看起来你正试图这样做,但你正在使用“http_headers”。请尝试“mime_type”:

  - url: /home/font/(.*\.otf)
    static_files: home/font/\1
    upload: home/font/(.*\.otf)
    mime_type: application/x-font-otf

我希望这对你有用。文档位于:

https://developers.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Static_file_handlers

答案 1 :(得分:3)

同样值得注意的是,通用规则应该是最后的,如下所示:

handlers:
- url: /static/fonts/(.*\.otf)
  static_files: static/fonts/\1
  upload: static/fonts/(.*\.otf)
  mime_type: application/x-font-otf

- url: /static/fonts/(.*\.ttf)
  static_files: static/fonts/\1
  upload: static/fonts/(.*\.ttf)
  mime_type: application/x-font-ttf

- url: /static
  static_dir: static