Created
February 7, 2015 19:53
-
-
Save javereec/592814e76a6f9f95b40e to your computer and use it in GitHub Desktop.
File upload spree api
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
conn = Faraday.new(url: 'http://veran.lvh.me:3000/', params: { token: 'ac350077d3066be3d2ca79fd0586e1b1d386b88a5870a1c0' }) do |f| | |
f.request :multipart | |
f.request :url_encoded | |
f.adapter :net_http | |
end | |
response = conn.post('api/products/abacate-embalagem-de-1kg/images',{image: {attachment: Faraday::UploadIO.new('./image.jpg', 'image/jpeg')}}) | |
## | |
base_64_img = "" | |
url = "http://yebo.veran.com.br/api/products/abacate-embalagem-de-1kg/images" | |
c = Curl::Easy.http_post(url, {image: {attachment: "data:image/jpeg;base64,#{base_64_img}"}, token: 'ac350077d3066be3d2ca79fd0586e1b1d386b88a5870a1c0'}.to_json) do |curl| | |
curl.headers['Content-Type'] = 'application/json' | |
curl.headers['Accept'] = 'application/json' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment