Archived Forum Post

Index of archived forum posts

Question:

post image file to Parse.com

Apr 24 '14 at 15:16

I'm trying to find the right syntax to post an image file to Parse.com using Chilkat.http. Below is the sample code from the Parse.com site.

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

Anyone have experience doing this sort of thing?


Answer

  1. Use SynchronousRequest
  2. Set the HttpRequest.HttpVerb = "POST"
  3. HTTP Request headers (-H) are added via the HttpRequest.AddHeader method.
  4. Set the HttpRequest.ContentType = "image/jpeg"
  5. Load the JPG file into the HttpRequest's body via the LoadBodyFromFile or LoadBodyFromBytes method.
  6. Set the HttpRequest.Path equal to the path part of the URL, which is "/files/pic.jpg"
  7. The args passed to SynchronousRequest are the domain, port, sslFlag, and httpRequestObject. The domain is "api.parse.com", the port is 443, the sslFlag = true.