Created
April 10, 2013 02:09
-
-
Save justinmcp/5351183 to your computer and use it in GitHub Desktop.
Example using POST with AFMotion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = AFMotion::Client.build('https://api.example.com/') do | |
header 'X-Example-API-Key', '<KEY>' | |
authorization username: user.login, password: user.password | |
end | |
client.multipart.post('photos') do |result, form_data| | |
if form_data | |
form_data.appendPartWithFileURL(NSURL.fileURLWithPath(<image file>, isDirectory:false), | |
name:'photo file name', error:nil) | |
if !data.nil? | |
form_data.appendPartWithHeaders({ 'Content-Disposition' => 'form-data; name="metadata"', | |
'Content-Type' => 'application/json' }, | |
body:NSJSONSerialization.dataWithJSONObject(data, options:0, error:nil)) | |
end | |
elsif result | |
if result.success? | |
else | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment