How to add binary data to limit POST

I am trying to do the next POST in Parse Cloud using Curb gem

curl -X POST \
  -H "X-Parse-Application-Id: PARSE_APP_ID" \
  -H "X-Parse-REST-API-Key: PARSE_API_KEY" \
  -H "Content-Type: image/jpeg" \
  --data-binary '@myPicture.jpg' \
  https://api.parse.com/1/files/pic.jpg

with this:

curl = Curl::Easy.new("https://api.parse.com/1/files/lion.jpg")
curl.multipart_form_post = true
curl.headers["X-Parse-Application-Id"] = PARSE_APP_ID
curl.headers["X-Parse-REST-API-Key"] = PARSE_API_KEY
curl.headers["Content-Type"] = "image/jpg"
res = curl.http_post(Curl::PostField.file('file', image.path))

The download goes through 201, but it does not seem that the file got to the server correctly.

+5
source share
1 answer

It revealed:

curl = Curl::Easy.new("https://api.parse.com/1/files/lion.jpg")
curl.headers["X-Parse-Application-Id"] = PARSE_APP_ID
curl.headers["X-Parse-REST-API-Key"] = PARSE_API_KEY
curl.headers["Content-Type"] = "image/jpeg"
data = File.read('/Users/haider/Pictures/lion.jpg')
curl.post_body=data
curl.http_post
puts curl.body_str
+9
source

All Articles