How to upload a file through the JSON interface in Rails

I have a web service in Rails that, among all the others, should provide file upload functions to clients. Customers use JSON to communicate with the web service. I am using the Paperclip plugin to manage downloads.

The problem is that I do not know how to upload a file via JSON. Everything works in a web form, but I can not find information on how to consult my JSON request for sending files to the server. Can anyone help?

Regards, Angel of Kapazov

+4
source share
2 answers

You do not need to use Paperclip to load JSON files in rails. Use the following syntax to insert a file upload field into your view. To read JSON files in your controllers, import a JSON package to read the contents.

<%= file_field 'LABEL', 'QUERY_PARAMETER_NAME' %></p> 
0
source

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


All Articles