Using restclient with multi-page messages

I am using a restclient for a multi-page form to send data to a soothing web service (this is Panda's video encoding service). The trick is that the file I submit to the restclient (Technoweenie branch) comes from my own form that the user submits.

So let's get through this. A user uploads a file to my rails application. In my controller, it gets the file from params [: file]. Then I want to pass params [: file] to Panda using RestClient.

The error I get is on the Panda server. I noticed that the file parameter in the stack trace is also on the line (I assume Panda turns into a line for a more convenient stacktrace).

~ Started request handling: Wed Aug 12 18:05:15 +0000 2009 ~ Params: {"format"=>"html", "multipart"=>"true", "account_key"=>"SECURE_KEY", "action"=>"upload", "id"=>"SECURE_ID", "controller"=>"videos", "file"=>"#<File:0xcf02ca4>"} ~ 9bfb1750-6998-012c-4509-12313900b0f6: (500 returned to client) InternalServerErrorcan't convert nil into String /var/local/www/panda/app/models/video.rb:246:in `extname' /var/local/www/panda/app/models/video.rb:246:in `initial_processing' /var/local/www/panda/app/controllers/videos.rb:79:in `upload' 
+6
ruby ruby-on-rails rest-client
source share
3 answers

I doubt that you can really pass the CGI style load parameter from Rails to a restclient and expect it to work.

A regular download in Rails will have fairly additional attributes that are not related to the hosted resource (for example, the original file name, etc.), and the Rails download contains an IO with the actual file data. In addition, the file upload object in Rails may be a Tempfile descriptor and may be StringIO, depending on the size of the download.

What you really need to do is "repackage" your download for the client-client, to handle it correctly, and pass the re-packaged and rewind Tempfile object to the restclient. Perhaps you can just select the boot object itself, and not all the [: file] options

+1
source share

Confirm that your restclient action can save space first. If the action cannot be saved locally, then you will have a better idea where to look for problems when shooting.

+1
source share

It seems that the problem is with publishing the rest-client file, check out an alternative publishing method like curb, for example.

Many examples for publishing data on a multi-page form on this subject: Ruby: How to send a file via HTTP as multipart / form-data?

0
source share

All Articles