Andrey P.
Andrey P.

Reputation: 147

How to update Bigcommerce product image to image stored locally?

Why I can't update image this way?

Bigcommerce::createProductImage($product_id, array('image_file'=>'/home/user/bigcommerce/api/picture.jpg'));

The follow code works:

Bigcommerce::createProductImage($product_id, array('image_file'=>'https://cdn6.bigcommerce.com/s-0cvdh/products/32/images/299/apitec71q__46081.1484240387.1280.1280__30161.1484331218.1280.1280.jpg'));

Upvotes: 0

Views: 256

Answers (2)

CueBallSTL
CueBallSTL

Reputation: 11

It doesn't work because the BigCommerce servers have no idea where "/home/user/bigcommerce/api/picture.jpg" lives. That's a file that exists on your local machine, and you're passing a string to BigCommerce telling it where to get the file. It works in the second case because BigCommerce can access that URI.

In more general terms, you need to upload the image to a location that BigCommerce can access it, and then pass a URI that BigCommerce can use to retrieve the image. It may seem a little cumbersome, but it relieves BigCommerce from having to stream large amounts of data through their API.

Upvotes: 0

user6438501
user6438501

Reputation:

According to the documentation, it is not possible to upload an image locally. The docs say:

When specifying a product image, the image_file should be specified as either: 
a path to an image already uploaded via FTP to the import directory (with the path 
relative to the import directory); or a URL to an image accessible on the internet.

Upvotes: 1

Related Questions