Rails application, loading via API, verification through curl

How can I make a photo application to receive images (and process them using paperclip) through the built-in API using the paperclip plugin. My application works great when downloading from a browser. How can I check the API using curl command? How to specify the endpoint url?

thank.

+3
source share
1 answer

To begin with, it can be easy to install Firebug or a similar tool and take a look at the sent request sent when the image is downloaded via the browser. The reason you need it is because the parameters can be named based on your rail model. Example:

Let's say your model is photographs. And let the URL be "http: // localhost: 3000 / pictures". Then the team will be 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. Other options will vary depending on your application. -F must be executed before the parameter itself.

If your application has authentication, use the following command.

curl --user user:password http://localhost:3000/pictures -F commit=Save -F picture[photo]=@test.jpg
+3
source

Source: https://habr.com/ru/post/1768999/


All Articles