Re: uploaded pictures are in a bad shape

Lennon Day-Reynolds <rcoder@...>

I think your problem here is using the form encoding of the payload, not anything related to the content type or use of IO vs. File.

What happens if you try something like the version below? (I would try it myself, but I don't actually use/have access to Parse.)

open('yo.jpg') do |fh|
'', fh,
{ :content_type => 'image/jpeg', :'X-Parse-Application-Id' => '…', :'X-Parse-REST-API-Key' => '…' }

From my reading of the current RestClient source, it looks like the above (passing the payload as a string, rather than a hash of form field values) should directly pass the raw image data, instead of encoding it as an HTML form. (Also, note the block form of opening the file; your version would leak open file handles if it ran in a persistent context like a Rails controller, due to never closing the opened File instance.)

<api-design-rant>As an aside: WTF is up with using a POST to a fixed resource URL as a means to do a file upload? Parse supports PUT elsewhere in their API, and that seems like a strictly better approach to use here, as well.</api-design-rant>

Hope that helps,


Lennon Day-Reynolds
rcoder@... // @rcoder

On Sunday, December 9, 2012 at 3:02 PM, Fernando Usero wrote:

Hi guys,

I am having a really weird beahaviour and I am bit frustrated with this because I cannot see what more to test.

I am uploading a jpg pic to ( and when downloading it, it never never is recognized as a jpg file. It seems to be the jpg file with some text placed at the beginning:

Content-Disposition: form-data; name="upload[file]"; filename="yo.jpg"
Content-Type: image/jpeg

I am using this restclient command:

<<<< '',
{ :upload => { :file =>'yo.jpg') } },
{ :content_type => "image/jpg", :"X-Parse-Application-Id" => XXXX, :"X-Parse-REST-API-Key"=> YYYY }
However using the translation to curl it works smoothly and the jog file can be downloaded again:

curl -X POST -H "X-Parse-Application-Id: XXXX" -H "X-Parse-REST-API-Key: YYYY" -H "Content-Type: image/jpeg" --data-binary '@yo.jpg'

i tried several things:

- Trying to use instead of (read in this mailing list)
- Tryin to change to content-type tp image/jpg instead of image/jpg
- Trying to set multipart => true and false

Any hint? Any clue?

Join to automatically receive all group messages.