How could I upload an image for a product using a nodejs api? I am developing a service with NodeJs with which, through the Woocommerce API, I create, update, view and delete orders, customers and products from a Woocommerce store. The thing is that I can't find a way to upload an image for each product. I've been researching, and I can't find a way. Any ideas? The woocommerce API does not have this functionality.
Yes, there is a solution, and there are several, here I present one of them:
I have found a solution, which is currently valid. It is about using the JavaScript client: "wordpress", XML-RCP Wordpress API.
Once we have the client we can proceed to process the image and use the "uploadFile" method. Documentation for this can be obtained at:
https://codex.wordpress.org/XML-RPC_WordPress_API or at https://www.npmjs.com/package/wordpress
Let's be clear that the NodeJS FyleSystem Promises API is still experimental.
Usage example:
We get the image data through fsPromises.readFile() and what we get we will place in the bits property. With this we should have uploaded the image. Among other data, the URL of the image will be returned within the "link" property once uploaded, and this can be used to update the "images" property of the product, for example. I hope that was clear, if any explanation is needed more than anyone feel free to ask. All the best.