Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this questionHow can i make my photo rails app to receive images (and handling them with paperclip) through the built in API using paperclip plugin. My app works fine w开发者_如何学Gohen upload from browser..How can i test the API with curl command? How can specify the end-point url?
thanks.
To begin with it may be easy to install Firebug or a similar tool and take a look at the post request being sent when you upload an image through browser. The reason you need this is because the parameters may be named based on your rails model. Example:
Lets say your model is pictures. And let the url be "http://localhost:3000/pictures". Then the command would something like this.
curl http://localhost:3000/pictures -F commit=Save -F picture[photo]=@test.jpg
commit=Save is the name and value of the submit button of your form. The other parameters would vary as per your application. -F needs to go before very parameter.
In case your application has authentication, use the below command.
curl --user user:password http://localhost:3000/pictures -F commit=Save -F picture[photo]=@test.jpg
精彩评论