I am building a flash-based uploader for rails that allows multiple
files to be selected from a user''s hard drive and then put into a
queue for upload. This works great except that macromedia uploads
everything as "application/octet-stream". This means that displaying
the newly uploaded content inline is a pain because the browser asks
to download it first.
To get around this I am finding the file extension and overriding the
content_type variable with my new variable from a look up list for
example "jpg" would then use image/jpeg. This works well with most
images however some do not display correctly and I get this error:
def find_flash_upload_mime_type (ext)
re = /(\.)/
md = re.match(ext)
type = case md.post_match.downcase
when "jpg" : "image/jpeg"
... more case statements for other file types ...
else "application/octet-stream"
end
return type
end
The image "http://localhost:3000/asset/show_data/120" cannot be
displayed, because it contains errors.
Though if I set the content_type back to "application/octet-stream"
and download it the file opens fine.
Does anyone know why this is happening?
Thanks,
Mark
--
--------------------------------------------------------------------
I am Mark Daggett and I approve this message.