it's been my experience that the browser cannot be trusted for sending
the correct mime type upon upload. firefox (all platforms) has been a
particularly bad offender, and i know that IE does some funny stuff,
too. (i can't believe it's 2008 and this basic functionality is still
broken! on second thought, i can. mime types and file extensions have
always been like the wild-west.)

in our recent projects that involve uploading files, we've used
mimetype-fu <> for determining
the correct/canonical (as far as mimetype-fu is concerned) mime type
to avoid two situations: 1) new/unexpected file types that users
upload and 2) consistent mapping of common file types
(application/msword vs. application/ vs. ???)

maybe paperclip should be patched to use mimetype-fu. it's pretty
inadequate for anything other than basic file types at the moment:

    # Infer the MIME-type of the file from the extension.
    def content_type
      type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
      case type
      when %r"jpe?g"                 then "image/jpeg"
      when %r"tiff?"                 then "image/tiff"
      when %r"png", "gif", "bmp"     then "image/#{type}"
      when "txt"                     then "text/plain"
      when %r"html?"                 then "text/html"
      when "csv", "xml", "css", "js" then "text/#{type}"
      else "application/x-#{type}"

probably not the answer you're looking for, but hth,


On Tue, Oct 21, 2008 at 1:32 PM, Jeffrey Jones <[EMAIL PROTECTED]> wrote:
> Finally figured out what it was.
> My version of Firefox (Firefox on Kubuntu linux) didn't know the video/x-flv
> mime-type so when it uploaded the file it was setting the content type as
> application/octet-stream. It appears paperclipped uses the browser mime-type
> to determine if the file is allowed to be uploaded or not (I assumed it
> checked the file).
> Adding the mime-type to Firefox solved the issue.
> On Kubuntu create a ~/.mime.types file with
> video/x-flv                flv
> (The master mime-type file is /etc/mime.types)
> I do not know if this affects windows Firefox or how you would add the
> mime-type in windows.
> Cheers
> Jeff
> Jeffrey Jones wrote:
>> Hoi all.
>> Has anyone managed to upload flash video files using the paperclipped
>> extension? I added video/x-flv to the allowed mime types but the FLVs are
>> still getting rejected as not allowed.
Radiant mailing list

Reply via email to