Date
1 - 5 of 5
how can I upload .png file without multipart?
Timothy Fong <timfong888@...>
This is how I am doing it, am I doing this right? I get a 200 response,
but still issues. @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 xxxxxeeeeexxxxxx' } # end headers ) #close arguments to Restclient.post
|
|
Archiloque <code@...>
Le 28 mai 2010 à 19:18, Timothy Fong a écrit :
This is how I am doing it, am I doing this right? I get a 200 response,It seems good, what specific issue do you have ? A.
|
|
Timothy Fong <timfong888@...>
According to the web service, they say it is being uploaded as
multi-part, and that is messing up the file on their end.
Archiloque wrote: Le 28 mai 2010 à 19:18, Timothy Fong a écrit :This is how I am doing it, am I doing this right? I get a 200 response, but still issues. @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 xxxxxeeeeexxxxxx' } # end headers ) #close arguments to Restclient.postIt seems good, what specific issue do you have ? A.
|
|
Archiloque <code@...>
In this case you could read the file into a string before sending it:
toggle quoted messageShow quoted text
@response = RestClient.post('http://www.postful.com/service/upload', {:upload => { :file => IO.read("#{@postalcard.postalimage.path}") } }, {"Content-Type" => @postalcard.postalimage.content_type, "Content-Length" => @postalcard.postalimage.size, "Authorization" => 'Basic xxxxxeeeeexxxxxx' } # end headers ) #close arguments to Restclient.post does it work ? A.
Le 30 mai 2010 à 19:31, Timothy Fong a écrit :
|
|
Timothy Fong <timfong888@...>
Let me try that. Once I am done, I need to post an XML, which I am
putting into an object. Not clear from the examples how to do it:
Does this look right?
@response_post = RestClient.post 'http://www.postful.com/service/mail',@xml_manual, {:Authorization => 'Basic dxxxxxx='} @xml_manual is built from XMl Builder, but to test it I just used a string as follows: @xml_manual = '<?xml version="1.0" encoding="UTF-8"?><mail><documents><document><template><source>gallery</source><name>Postcard: Image fill front</name></template><sections><section><name>text</name><text>Hello, world</text></section><section><name>Image</name><attachment>267551773-3425</attachment></section></sections></document></documents><addressees><addressee><name>John Doe</name><address>123 Main St</address><city>Anytown</city><state>AZ</state><postal-code>10000</postal-code></addressee></addressees></mail>' Archiloque wrote: In this case you could read the file into a string before sending it:
|
|