Skip to content

Instantly share code, notes, and snippets.

@justinmcp
Created April 10, 2013 02:09
Show Gist options
  • Save justinmcp/5351183 to your computer and use it in GitHub Desktop.
Save justinmcp/5351183 to your computer and use it in GitHub Desktop.
Example using POST with AFMotion
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