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/2.0/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