Reputation: 30276
I'm using Android device to upload file to server by using POST method. But I don't know how to make Rails handle this event. It means, after Android device sends file to server by method POST by the link : http://localhost/upload_file
, rails server can handle this event, and put this file into database, for example.
I have google and some results that tell me use additional plugin. Does exist any pure method just use rails only ? Please tell me.
Thanks :)
Upvotes: 0
Views: 6612
Reputation: 1703
Rails can handle file uploads pretty easily. Here is the relevant guide that you should read: http://guides.rubyonrails.org/form_helpers.html
Here's a small snippet from the guide:
5.1 What Gets Uploaded
The object in the params hash is an instance of a subclass of IO. Depending on the size of the uploaded file it may in fact be a StringIO or an instance of File backed by a temporary file. In both cases the object will have an original_filename attribute containing the name the file had on the user’s computer and a content_type attribute containing the MIME type of the uploaded file.
Upvotes: 2