mime-types / ruby-mime-types

Ruby MIME type registry library
Other
322 stars 122 forks source link

Splitted 7z file -> mime type "" #144

Closed andreas-it-dev closed 5 years ago

andreas-it-dev commented 5 years ago

While using active storage the upload of some files fails with the error:

Mime::Type::InvalidMimeType - "" is not a valid MIME type

it seems to fail coz the uploaded files are splitted 7z files. their extensions is something like foo.7z.001, foo.7z.002 and so on.

7z files seems to be identified in lib/mime/types/application.nonstandard via the file extension(?)

application/x-7z-compressed @7z '{7zip=http://www.7-zip.org/7z.html}

you guys could also add the splitted versions?

thanks a lot! Andreas

halostatue commented 5 years ago

Sorry, but this is a change that cannot be implemented by mime-types.

Any file type that supports splitting/joining could be these extensions, not just 7z files, and the number of possible split extensions is infinite.

You’ll be better looking into how to fix the logic so that if you detect a split part, you check the MIME type on the file without the split extension. I recommend opening an issue either with ActiveStorage or with the backend you’re using for ActiveStorage (I haven’t used ActiveStorage, so I don’t exactly know how this works).