You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Joseph Page edited this page Jan 4, 2018
·
1 revision
because oauth2 is using faraday gem to do the http request.
so we can upload image in faraday way.
the block passing to OAuth2::Client is the one to Faraday::Builder
your can read faraday#advanced-middleware-usage to understand how it work.
here are two key part to upload image.
begin
img = Faraday::UploadIO.new('play.gif', 'image/gif')
data = {:content => "this is a tile", :img => img}
response = token.post('api/v1/tiles/', :body => data)
print response.body, response.status
rescue OAuth2::Error => e
puts e
end