I add user-uploaded videos to the RoRs site using paperclip gem and s3 memory. For some reason, I canโt understand when the user downloads the mp4 file, s3 sets the content type for this file as application/mp4
instead of video/mp4
.
Note that I registered the mime mp4 type in the initialization file:
Mime::Type.lookup_by_extension('mp4').to_s => "video/mp4"
Here is the relevant part of my Post model:
has_attached_file :video, :storage => :s3, :s3_credentials => "#{Rails.root.to_s}/config/s3.yml", :path => "/video/:id/:filename" validates_attachment_content_type :video, :content_type => ['video/mp4'], :message => "Sorry, this site currently only supports MP4 video"
What I miss in the settings of the paper clip and / or s3.
#### Update #####
For some reason I don't know Rails, my default mime types for files containing mp4 are as follows:
MIME::Types.type_for("my_video.mp4").to_s => "[application/mp4, audio/mp4, video/mp4, video/vnd.objectvideo]"
So, when paperclip sends the mp4 file to s3, it seems to identify the mime file type as the first default "application / mp4". This is why s3 identifies the file as having the content type โapplication / mp4โ. Since I want to enable streaming of these mp4 files, I need a folder to identify the file as having a mime type of "video / mp4".
Is there a way to change the paperclip (possibly in the before_post_process filter) to allow this, or is there a way to change the rails through the initialization file to identify mp4 files as "video / mp4". If I could do what is best.
thanks for the help