Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:49:20+00:00 2026-06-08T13:49:20+00:00

I am adding user uploaded videos to my RoRs site with the help of

  • 0

I am adding user uploaded videos to my RoRs site with the help of the paperclip gem and s3 storage. For some reason that I can’t figure out, whenever a user uploads an mp4 file, s3 sets content-type for that file as application/mp4 instead of video/mp4.

Note that I have registered mp4 mime type in an initializer 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 am I missing in my paperclip and/or s3 set-up.

####Update#####

For some reason that is beyond my knowledge of Rails, my default mime types for mp4 contained files is the following:

    MIME::Types.type_for("my_video.mp4").to_s
 => "[application/mp4, audio/mp4, video/mp4, video/vnd.objectvideo]" 

So, when paperclip send an mp4 file to s3, it seems to identify the file’s mime type as the first default, “application/mp4”. That is why s3 identifies the file as having a content-type of “application/mp4”. Because I want to enable streaming of these mp4 files, I need paperclip to identify the file as having a mime type of “video/mp4”.

Is there a way to modify paperclip (maybe in a before_post_process filter) to allow for this, or is there a way to modify rails through an init file to identify mp4 files as being “video/mp4”. If I could do either, which way is best.

Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:49:22+00:00Added an answer on June 8, 2026 at 1:49 pm

    Turns out that I needed to set a default s3 header content_type in the model. This isn’t the best solution for me because at some point I might start allowing video containers other than mp4. But it gets me moving on to the next problem.

      has_attached_file :video, 
                    :storage => :s3,
                    :s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
                    :path => "/video/:id/:filename",
                    :s3_headers =>  { "Content-Type" => "video/mp4" }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some buttons that get disabled when adding a user. What I need
I have a page where the user can dynamically add file upload boxes. Adding
I have a textarea, where the user can add their comments. Now after adding
I have a user-uploaded image pulled from the database that I am resizing smaller
Is there an existing gem for adding user-defined field functionality to an existing Ruby
I am adding user controls to a panel that is empty, but when i
I am adding a user control dynamically on a page, the user control has
I'm adding a user defined function to Excel with varargs-based signature in C++: LPXLOPER
Here is my powershell code for adding test user accounts to Active directory... Problem:
I've got a ViewModel for adding a user with properties: Email, Password, ConfirmPassword with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.