Using rest-client to upload a paperclip attachment but getting no file found error

Posted by Angela on Stack Overflow See other posts from Stack Overflow or by Angela
Published on 2010-05-23T21:18:29Z Indexed on 2010/05/23 21:20 UTC
Read the original article Hit count: 509

Filed under:
|

Hello,

I have a paperclip attachment that I wan to upload to a web-service using rest-client. However, when I try to run it, I get an error:

No such file or directory - /system/postalimages/1/original/postcard-1.png?1274635084

But the file exists for sure: I see it in my directory. How do I debug this?

Here is the code in my controller which makes the upload:

def upload
    @postalcard = Postalcard.find(:last)

    response = RestClient.post('http://www.postful.com/service/upload', {
                  :upload => {
                    :file => File.new(@postalcard.postalimage.url,'rb')
#paperclip file path
                   }
                }, #end payload
                {"Content-Type" => @postalcard.postalimage.content_type,
                 "Content-Length" => @postalcard.postalimage.size,
                 "Authorization" => 'Basic dGltZm9uZzg4OEBnbWFpbC5jb206ZDlQcTVKUU4='}
# end headers
               ) #close arguments to Restclient.post

    return response.body
       end

© Stack Overflow or respective owner

Related posts about paperclip

Related posts about rest-client