I have an application built into ruby ββon rails. I need to send a curl request to this application to download images from a local computer. In my ruby ββon rails application, I use paperclip for the image downloader.
Now this curl request works fine, since there is no downloadable image for this curl request:
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
Now I want to download an image from my local machine.
Adding "display_photo": @ test.jpg does not work: this is what I tried: (But its not working.)
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
So the question is how to load images / data files / videos from curl request
EDIT
This is my controller:
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
format.json { render :file => "users/json/show.json.erb", :content_type => 'application/json' }
else
format.html { render :action => "edit" }
format.json {
@errors_object = @user
render :file => "shared/json/errors.json.erb", :content_type => 'application/json' }
end
end
end
In my model:
class User < ActiveRecord::Base
has_attached_file :display_photo, :styles => { :medium => "200x200#", :thumb => "100x100#", :very_small=>"24x24#" }
end
source
share