title: Curl request to upload image from local machine to ruby on rails application
body: <p>I have an application built in ruby on rails. I need to post curl request to that application to upload images from local machine. In my ruby on rails application I am using paperclip for image uploader.</p>
  
  <p>Now this curl request is working perfectly fine as there is no upload image for this curl request:</p>
  
  <pre><code>  curl -v -H   "Accept: application/json" -H "Content-type: application/json" -X PUT -d '{"user":{"first_name":"John","last_name":"Smith"},"token":"api"}'  http://localhost:3000/users/8
  </code></pre>
  
  <p>Now I want to upload an image from my localmachine.</p>
  
  <p>Adding "display_photo":@test.jpg is not working: This is what I was trying: (<em>But its not working</em>.)</p>
  
  <pre><code>  curl -v -H  -F "Accept: application/json" -H "Content-type: application/json" -X PUT -d '{"user":{"first_name":"firstname","last_name":"lastname","display_photo":@test.jpg},"token":"api"}'  http://localhost:3000/users/8
  </code></pre>
  
  <p>So the question is how to upload images/data files/ videos from curl request</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is my controller:</p>
  
  <pre><code>   def update
      @user = User.find(params[:id])
  
      respond_to do |format|
        if @user.update_attributes(params[:user])
          format.html {  redirect_to(@user, :notice =&gt; 'User was successfully updated.') }
          format.json  { render :file =&gt; "users/json/show.json.erb", :content_type =&gt; 'application/json' }
        else
          format.html { render :action =&gt; "edit" }
          format.json  { 
            @errors_object = @user
            render :file =&gt; "shared/json/errors.json.erb", :content_type =&gt; 'application/json' }
        end
      end
    end
  </code></pre>
  
  <p>In my model:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
      has_attached_file :display_photo, :styles =&gt; { :medium =&gt; "200x200#", :thumb =&gt; "100x100#", :very_small=&gt;"24x24#" }
  end
  </code></pre>