title: rails uploading file to Amazon S3
body: <p>I want to upload files directly to AmazonS3 from my Rails application. config looks like this at the moment:</p>
  
  <p><strong>Gemfile</strong></p>
  
  <p>gem "paperclip"</p>
  
  <p>gem 'aws-sdk'</p>
  
  <p><strong>In config/application.rb</strong></p>
  
  <pre><code># Amazon S3 configuration for paperclip
  config.paperclip_defaults = {
      :storage =&gt; :s3,
      :s3_host_name =&gt; 's3-eu-west-1.amazonaws.com'
  }
  </code></pre>
  
  <p><strong>Model - movie.rb</strong></p>
  
  <pre><code>class Movie &lt; ActiveRecord::Base
  
     # add File to Movie association on column mo
     has_attached_file :movie,
                  :storage =&gt; :s3,
                  :bucket =&gt; '--',
                  :s3_credentials =&gt; {
                      :bucket =&gt; '---',
                      :access_key_id =&gt; '---',
                      :secret_access_key =&gt; '---'
                  }
  
    # validdates the file type
    validates_attachment_content_type :movie, :content_type =&gt; /\Avideo\/.*\Z/
  
  end
  </code></pre>
  
  <p><strong>Controller movies_controller.rb</strong></p>
  
  <pre><code>class MoviesController &lt; ActionController::Base
  
    layout "application"
  
    # Method to add a new Movie
    def addMovie
  
      if request.post?
        #@movie = Movie.new(movies_params)
        @movie = Movie.new(params[:movie])
        if @movie.save
          flash[:notice] = t("flash.moveuploadstarted")
          redirect_to :addMovie
        end
      else
        @movie = Movie.new
      end
    end
  
  
    private
  
     def movies_params
      params.require(:movie).permit(:movietitle, :movieprice, :locked,    :moviedescription, :currency, :language)
    end
  
  end
  </code></pre>
  
  <p>Database looks like this:
  <a href="https://i.stack.imgur.com/Qgyj7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qgyj7.png" alt="enter image description here"></a></p>
  
  <p>When I fill my form and send the movie the browser starts to upload the movie the persentage is shown on left bottom corner. But when 100% are reached the movie isn't stored to Amazon S3 and DB is empty, but no errors or so....</p>
  
  <p>What could be the problem? .</p>
  
  <p>UPDATE:</p>
  
  <p>upload form has this input file for the video</p>
  
  <pre><code>    &lt;div class="form-group"&gt;
        &lt;label&gt;&lt;%= f.label :movie %&gt;&lt;/label&gt;
        &lt;%= f.file_field :movie, :class =&gt; "form-control", :placeholder =&gt; :movie %&gt;
      &lt;/div&gt;
  </code></pre>