Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not guess mimetype

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/\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
like image 368
Gert Cuykens Avatar asked Dec 06 '13 13:12

Gert Cuykens


People also ask

What is MIME type?

A MIME type (now properly called "media type", but also sometimes "content type") is a string sent along with a file indicating the type of the file (describing the content format, for example, a sound file might be labeled audio/ogg , or an image file image/png ).

What is mimetypes in python?

The mimetypes module converts between a filename or URL and the MIME type associated with the filename extension. Conversions are provided from filename to MIME type and from MIME type to filename extension; encodings are not supported for the latter conversion.

What is the default MIME type?

Two primary MIME types are important for the role of default types: text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data. application/octet-stream is the default value for all other cases.

Is content type same as MIME type?

content_type is an alias for mimetype. Historically, this parameter was only called mimetype, but since this is actually the value included in the HTTP Content-Type header, it can also include the character set encoding, which makes it more than just a MIME type specification.


1 Answers

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/\1
    upload: home/font/(.*\.otf)
    mime_type: application/x-font-otf

I hope that works for you. The documentation is at:

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

like image 71
Yves Junqueira Avatar answered Sep 20 '22 14:09

Yves Junqueira