1

私は次のことを試みましたが、Web サービスは REST ではなく、マルチパートを取りません。画像を投稿するにはどうすればよいですか?

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

1 に答える 1

1

答えを得ました:File.new ...を使用する代わりに、I/Oを使用して文字列としてストリーミングします。

:file => IO.read("#{@postalcard.postalimage.path}")
于 2010-06-02T04:42:48.467 に答える