1
votes

I am writing a blog for games, loading files with extension *.sgf Sinatra doesn't recognize this.

Unknown media type: ".sgf" file: base.rb location: content_type line: 132

The backtrace mentions webrick

/usr/lib/ruby/1.9.1/webrick/httpserver.rb in service si.service(req, res) /usr/lib/ruby/1.9.1/webrick/httpserver.rb in run server.service(req, res) /usr/lib/ruby/1.9.1/webrick/server.rb in block in start_thread block ? block.call(sock) : run(sock)

I caught this since although my Sinatra app works when I do ruby myApp.rb it doesn't work when I do foreman start for Heroku (and it didn't work when I deployed).

1

1 Answers

3
votes

You should configure Sinatra to understand your MIME-type:

configure do
  mime_type :sgf, 'application/octet-stream'
end

or inplace:

get '/upload' do
  content_type :sgf
  # Do what you want with the file
end

More info.