在测试服务器上,goapp serv它可以工作;在Appengine上,它会被application / octet-stream覆盖。
goapp serv
我如何告诉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
我相信它在本地运行的原因是您的系统在/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