File upload with REST POST?

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
the .REST POST?

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

Thanks
Chirag

PS. I’m using attachment_fu plugin which automatically creates a REST
controller on the server side

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?

password is the field name and /etc/passwd is the file (on the file
system) you want to upload.

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 www.mypasswords.com

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

If curl can do it, I’m betting that .Net can too. :slight_smile:

I tried the following comnmand
curl -F “[email protected]
http://localhost:3000/raw_data_files/create

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| %>

Upload a file: <%= form.file_field :uploaded_data %>

<%= submit_tag "Create" %>

<% end %>

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

Chirag