英文:
Could not guess mimetype
问题
在测试服务器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/
upload: home/font/(.*\.woff)
http_headers:
Content-Type: application/font-woff
- url: /home/font/(.*\.svg)
static_files: home/font/
upload: home/font/(.*\.svg)
http_headers:
Content-Type: image/svg+xml
- url: /home/font/(.*\.eot)
static_files: home/font/
upload: home/font/(.*\.eot)
http_headers:
Content-Type: application/vnd.ms-fontobject
- url: /home/font/(.*\.ttf)
static_files: home/font/
upload: home/font/(.*\.ttf)
http_headers:
Content-Type: application/x-font-ttf
- url: /home/font/(.*\.otf)
static_files: home/font/
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
英文:
On the test server goapp serv
it works, on the appengine itself it get overwritten by application/octet-stream.
How can I tell appengine to stop doing that?
Could not guess mimetype for home/fonts/FontAwesome.otf. Using application/octet-stream...
My config file:
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/
upload: home/font/(.*\.woff)
http_headers:
Content-Type: application/font-woff
- url: /home/font/(.*\.svg)
static_files: home/font/
upload: home/font/(.*\.svg)
http_headers:
Content-Type: image/svg+xml
- url: /home/font/(.*\.eot)
static_files: home/font/
upload: home/font/(.*\.eot)
http_headers:
Content-Type: application/vnd.ms-fontobject
- url: /home/font/(.*\.ttf)
static_files: home/font/
upload: home/font/(.*\.ttf)
http_headers:
Content-Type: application/x-font-ttf
- url: /home/font/(.*\.otf)
static_files: home/font/
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
答案1
得分: 25
我相信它在本地工作的原因是你的系统在/etc/mime.types或等效位置中定义了.otf扩展名所需的MIME类型。
AppEngine可能没有这个。所以你需要给它一个关于正确MIME类型的提示。看起来你正在尝试做到这一点,但你正在使用"http_headers"。请尝试使用"mime_type"代替:
- url: /home/font/(.*\.otf)
static_files: home/font/
upload: home/font/(.*\.otf)
mime_type: application/x-font-otf
希望对你有用。文档在这里:
英文:
I believe the reason it's working locally is that your system has the required mime type defined for the .otf extension in the /etc/mime.types or equivalent.
AppEngine probably doesn't have that. So you have to give it a hint about the correct MIME type. It looks like you're trying to do but, but you are using "http_headers". Try "mime_type" instead:
- url: /home/font/(.*\.otf)
static_files: home/font/
upload: home/font/(.*\.otf)
mime_type: application/x-font-otf
I hope that works for you. The documentation is at:
答案2
得分: 3
值得注意的是,通用规则应该放在最后,像这样:
处理程序:
- url:/static/fonts/(.*\.otf)
static_files:static/fonts/
upload:static/fonts/(.*\.otf)
mime_type:application/x-font-otf
- url:/static/fonts/(.*\.ttf)
static_files:static/fonts/
upload:static/fonts/(.*\.ttf)
mime_type:application/x-font-ttf
- url:/static
static_dir:static
英文:
It's also worth noting that generic rule should go last, like this:
handlers:
- url: /static/fonts/(.*\.otf)
static_files: static/fonts/
upload: static/fonts/(.*\.otf)
mime_type: application/x-font-otf
- url: /static/fonts/(.*\.ttf)
static_files: static/fonts/
upload: static/fonts/(.*\.ttf)
mime_type: application/x-font-ttf
- url: /static
static_dir: static
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论