如何将 Bigcommerce 产品图片更新为本地存储的图片?

How to update Bigcommerce product image to image stored locally?

为什么我不能用这种方式更新图片?

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

以下代码有效:

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'));

根据documentation,无法在本地上传图片。文档说:

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.

它不起作用,因为 BigCommerce 服务器不知道“/home/user/bigcommerce/api/picture.jpg”在哪里。这是一个存在于您本地计算机上的文件,您将一个字符串传递给 BigCommerce,告诉它从哪里获取该文件。它适用于第二种情况,因为 BigCommerce 可以访问该 URI。

更一般地说,您需要将图像上传到 BigCommerce 可以访问它的位置,然后传递 BigCommerce 可以用来检索图像的 URI。这可能看起来有点麻烦,但它使 BigCommerce 不必通过他们的 API.

传输大量数据。