Forum: NGINX Incorrectly getting mime-type for flv files

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fernando P. (Guest)
on 2009-05-26 11:32
Hi,

I use Nginx in front of a Ruby on Rails application. When I upload an
flv file that will be processed by Paperclip, I always get the mime-type
as application/octet-stream although I have a mime.types file included
in nginx' configuration file.

My flv files on disk have a mime-type of application/octet-stream, but
Nginx shouldn't care and when he sees a file coming in he should reset
the mime-type (I guess). Where could the problem come from?

Best regards,
Jean-Philippe M. (Guest)
on 2009-05-26 11:53
(Received via mailing list)
Fernando P. a écrit :
> Hi,
>
> I use Nginx in front of a Ruby on Rails application. When I upload an
> flv file that will be processed by Paperclip, I always get the mime-type
> as application/octet-stream although I have a mime.types file included
> in nginx' configuration file.
>
If you are refering to the mime type reported by paperclip (and inserted
into the db), this has nothing to do with the mime type that nginx uses.
Actually the mime type paperclip uses is taken from the user agent. If
it doesn't suit your needs use a hook in your rails model or a custom
paperclip processor.
Fernando P. (Guest)
on 2009-05-26 12:20
> If you are refering to the mime type reported by paperclip (and inserted
> into the db), this has nothing to do with the mime type that nginx uses.
> Actually the mime type paperclip uses is taken from the user agent. If
> it doesn't suit your needs use a hook in your rails model or a custom
> paperclip processor.
Exactly. So what to use to correctly detect the content-type of an flv
file so that I can authorize it in paperclip? Plug mimetype_fu in?
Igor S. (Guest)
on 2009-05-26 14:19
(Received via mailing list)
On Tue, May 26, 2009 at 10:20:27AM +0200, Fernando P. wrote:

> > If you are refering to the mime type reported by paperclip (and inserted
> > into the db), this has nothing to do with the mime type that nginx uses.
> > Actually the mime type paperclip uses is taken from the user agent. If
> > it doesn't suit your needs use a hook in your rails model or a custom
> > paperclip processor.
> Exactly. So what to use to correctly detect the content-type of an flv
> file so that I can authorize it in paperclip? Plug mimetype_fu in?

nginx sets content-type depending on extension. If your flv have no
extensions you may set default mime-type for location:

locaiton /flvs/ {
    default_type  video/x-flv;
    ...
}
This topic is locked and can not be replied to.