application/octet-stream WTF?

December 17th, 2008

Lately I’ve been having this problem with uploaded files using the Paperclip plugin (though I don’t think it has anything to do with the plugin).

My customers are trying to upload CSV files to their Donor Tools account. Normally, when you upload a .csv file, the content type is set to “text/csv” or some variation of “text/*”.

Here’s the problem: when uploading .csv files in Windows using any version of IE or Firefox, the content type is set to “application/octet-stream”.

What the flip?

This only occurs with IE or Firefox. Safari for Windows uploads the exact same file with the content type set correctly to “text/csv”.

To get around the problem I’ve temporarily turned off the file type validation, which I don’t like because I really don’t want to be accepting uploaded binary files.

Has anyone seen this problem before? How did you deal with it?

3 Responses to “application/octet-stream WTF?”

  1. Jörg Battermann Says:

    Hello there,

    well whenever uploads come in with octet-stream (same happens when you use flash/swfupload etc), I use the mime-types gem in the corresponding model like so:

    has_attached_file :photo,
                      :storage => :s3,
                      :s3_credentials => "#{RAILS_ROOT}/config/s3.yml,
                      :path =>",
                      :styles => {
                        :large => '768x768>',
                        :small => '128x128#',

    public def uploaded_data=(data) data.content_type = MIME::Types.type_for(data.original_filename).to_s = data end


    Now in the corresponding controller and its create action, I set the data explicitly like so:

    @photo.uploaded_data = params:photo

    The model is named Photo and the paperclip attachment-field, too.. kinda bad example, but I hope you get the idea :)


  2. Ryan Says:

    Thanks Jörg – I haven’t had a chance to try this, but I’ll post about how it goes.

  3. Jörg Battermann Says:

    sure thing… formatting is a tad messed up up there.. maybe you can see the actual code I posted (it’s missing some parts) in your blog’s admin center or so… not sure. if not, just send me a mail…

    cheers, -j

Sorry, comments are closed for this article.