Wednesday, July 13, 2011

[Rails] RestClient posting multipart issue - RestClient::Found Exception: 302 Found

I thought I found how to post a file to my controller for PaperClip
attachment processing , but I am stuck with the the RestClient
processing

I am creating the file from the email attachment :
file = StringIO.new(part.decoded)
file.class.class_eval
{ attr_accessor :original_filename, :content_type }
file.original_filename = part.filename
file.content_type = part.mime_type

# then adding some parameters
fields_hash = {:clip => {:description => "uploaded file", :name =>
'test', :file => file }, :email_upload => true}

# setting the url => "http://localhost:3000/en_GB/users/clips"
@url = "http://#{Rails.configuration.host}/#{locale}/users/clips"

# and finally sending the request
response = RestClient.post @url , fields_hash

and I get RestClient::Found Exception: 302 Found

what could be wrong ?


the form used in the clip create action is

<form accept-charset="UTF-8" action="http://localhost:3000/en_GB/users/
clips" enctype="multipart/form-data" method="post">
<input id="clip_name" name="clip[name]" size="30"" type="text">
<textarea cols="24" id="clip_description" name="clip[description]"
rows="5"></textarea>
<input id="clip_data" name="clip[data]" " type="file">
<input id="swing_submit" name="commit" type="submit" value="Upload">
</form>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate