5

I'm trying to do the following POST to Parse Cloud using the 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))

Upload goes through with a 201, but it doesn't seem like the file makes it up to the server correctly.

haider
  • 2,418
  • 3
  • 24
  • 26

1 Answers1

9

Figured it out:

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
haider
  • 2,418
  • 3
  • 24
  • 26