I am trying to upload local images to a Shopify product via node.js and shopify-api-node.
This is the part of the code, where I am uploading the images.
product.images.forEach(async image => {
Logger.toFile("product.image", image);
try {
await this._api.productImage.create(shopifyProduct.id, {
src: image.src
});
} catch (error) {
Logger.error("Error uploading images.");
this._handleErrors(error);
}
})
If I use an external URL for image.src, everything works just fine.
Here is the logger with working external URL:
[2022-02-01 16:44:38 UTC][Products] product.image {
src: 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/220px-Image_created_with_a_mobile_phone.png',
position: 1
}
And the not working local src:
product.image {
src: '/Users/radoslav/Server/projects/tmp/pics/264-426.png',
position: 1
}
The path is correct and the image 264-426.png exists.
Any suggestions, what I am doing wrong, or is it possible to upload an image to Shopify from a local link?