Forum: Ruby on Rails file upload with REST POST?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bbdc298cd824989df148bc5312ab4bc3?d=identicon&s=25 chirag (Guest)
on 2007-06-22 22:23
(Received via mailing list)
Does anyone know how I exactly I would post a file from a non-web
client? In my case, I want to upload different file formats
(.csv, .txt, etc) from the client's file system. How does this work
exactly if I'm not using a browser? What would be the format for

I'm using a .NET client new to that and not sure exactly how to POST
an external file from a non-web client through REST


PS. I'm using attachment_fu plugin which automatically creates a REST
controller on the server side
21f7ed21f11a809050594c82eab11d67?d=identicon&s=25 Robert Walker (Guest)
on 2007-06-23 03:14
(Received via mailing list)
You would send the file just like a browser would.  Use a multi-part
form with your file attached.

Here's an example of sending a file with curl:

curl -F password=@/etc/passwd

Notice the -F tells curl to use multipart/form-data according to

If curl can do it, I'm betting that .Net can too.  :-)
Bbdc298cd824989df148bc5312ab4bc3?d=identicon&s=25 chirag (Guest)
on 2007-06-23 21:48
(Received via mailing list)
I don't completely understand the "-F" switch

Is "password=@/etc/passwd" a path on the file system?

How would I send a .csv file in the same directory?
D707194949c58eb4076f040adf116508?d=identicon&s=25 Bruno Celeste (Guest)
on 2007-06-24 10:04
(Received via mailing list)
password is the field name and /etc/passwd is the file (on the file
system) you want to upload.
Bbdc298cd824989df148bc5312ab4bc3?d=identicon&s=25 chirag (Guest)
on 2007-06-28 17:44
(Received via mailing list)
I tried the following comnmand
curl -F "uploaded_data=@curltest.docx"
> results.html

and got the following errors from attachment_fu (file upload) plugin

There were problems with the following fields:
    * Content type can't be blank
    * Size is not included in the list
    * Size can't be blank
    * Filename can't be blank

Here's my view which works fine on the upload (unlike cURL):
<%= error_messages_for :raw_data_file %>

<% form_for(:raw_data_file, :url => raw_data_files_path, :html =>
{ :multipart => true }) do |form| %>
    <label for="uploaded_data">Upload a file:</label>
    <%= form.file_field :uploaded_data %>

  <p> <%= submit_tag "Create" %> </p>
<% end %>

How do I manually set the filename, size, and content type in cURL?

This topic is locked and can not be replied to.