uploaded pictures are in a bad shape


Fernando Usero <fusero@...>
 

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 parse.com 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:

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

I am using this restclient command:

<<<<
RestClient.post 'https://api.parse.com/1/files/yo.jpg',
{ :upload => { :file =>File.new('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' https://api.parse.com/1/files/yo.jpg
>>>>>

i tried several things:

- Trying to use IO.read instead of File.new (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 main@rest-client.groups.io to automatically receive all group messages.