Get file content type?

Hi,

I’m trying to get content_type value for uploaded file, but it always
return to me

application/octet-stream

even if it is video.avi or file.rb or any other music.mp3

is there anything special I need to do in my rails application?

//jamal

On Nov 15, 3:24 am, Jamal S. [email protected]
wrote:

//jamal

Posted viahttp://www.ruby-forum.com/.

you could try one fo these

http://blog.amodernfable.com/2006/11/12/file-upload-content-types-on-ruby-on-rails-one-liner/
http://www.db75.com/new_blog/?p=289

I just tried both of them out :slight_smile:

logger.info file_data.content_type.chomp
output => application/octet-stream

the same as before…

logger.info file_data.content_type.to_s.strip!
output => “”

empty…

On 15 Nov 2007, at 13:21, gene tani wrote:


Posted viahttp://www.ruby-forum.com/.

you could try one fo these

http://blog.amodernfable.com/2006/11/12/file-upload-content-types-
on-ruby-on-rails-one-liner/
http://www.db75.com/new_blog/?p=289

These two pages don’t deal with determining the filetype for
application-octet stream files, the content type just isn’t passed in
on upload (probably because you’re using a Flash uploader). You can
use mimetype_fu to determine the filetype, it works perfectly.

Best regards

Peter De Berdt

Thank you very much, it works now :slight_smile:

Since you guessed that the problem I’m facing is with Flash, you may
know how to validate the file before uploading it to the server?

when flash uploading progress is on 100% it execute the action method.