views:

267

answers:

2

Hi,

I have a web service in Rails which among all else should provide file upload functionality to the clients. The clients all use JSON to talk to the webservice. I use the Paperclip plugin for upload management.

The problem is I do not know how to upload a file via JSON. All works in the web formular, but I cannot find information on how to consctruct my JSON Request to send files to the server. Can somebody help out?

Regards, Angel Kafazov

A: 

You don't need to use Paperclip for uploading JSON files in rails. Use the following syntax inserting the file upload field to your view. To read the JSON files in your controllers, import JSON package to read the contents.

<%= file_field 'LABEL', 'QUERY_PARAMETER_NAME' %></p>
Snehal
Thanks for the reply, but I use JSON for everything else and would like to keep the API consistent.
akafazov
I finally used Paperclip for the file upload, but couldn't make it to work with JSON, only with regular HTTP.
akafazov
A: 

Did you ever find an answer for this?

bramswenson
No, I used paperclip but purely http based, no JSON upload.
akafazov