Hello, looking for some insight on this one
I first had troubles understanding why webm's files were not accepted, using with the following list of mime-types
VIDEO_FORMATS = [ 'video/mp4','video/webm','application/mp4', 'video/mp4', 'video/quicktime', 'video/avi', 'video/mpeg', 'video/x-mpeg', 'video/x-msvideo', 'video/m4v', 'video/x-m4v', 'video/vnd.objectvideo'].freeze
using
Attacher.validate do
validate_mime_type_inclusion [*IMAGE_FORMATS,*VIDEO_FORMATS,*AUDIO_FORMATS,*DOC_FORMATS]
end
I've added some tracing to debug, at different points :
plugin :determine_mime_type, analyzer: -> (io, analyzers) do
mime_type = analyzers[:file].call(io)
mime_type = analyzers[:mime_types].call(io) if mime_type == "text/plain"
mime_type
end
and
add_metadata do |io, context|
...
end
Turns out that :
- determine_mime_type that returns application/octet-stream
- MIME::Types.type_for returns and array [#<MIME::Type: audio/webm>, #<MIME::Type: video/webm>]
I expected shrine receiving video/webm only
You might be aware of, Shrine validates the first one, I add to include application/octet-stream in that accepted mime types
My problem is that, laking of enough knowledge in file types, it feels quite bad to declare an application/octet-stream to accept videos uploads on the app
Am i right to feel such setup unsafe ?
Thx for you help on that one