Image Upload Code Sample - Ruby with Typhoeus
Image Upload Code Sample - Ruby with Typhoeus
This code sample is using the Typhoeus library to simplify handling of the HTTP request.
require 'typhoeus'
url = "https://DOMAIN_PREFIX.retail.lightspeed.app/api/{version}/products/{product_id}/actions/image_upload"
request = Typhoeus::Request.new(
url,
method: :post,
headers: {
ContentType: 'multipart/form-data',
Authorization: 'Bearer {token}'
},
body: {
image: File.open("{file_path}")
}
)
response = request.run
puts response.body