Reputation: 153
I'm using Fastify-multipart v5.3.1 with fastify v3 (for compatibility reasons) I use it to upload files from the client to the server and then from the server to Shopify.
From client to our server the files are transferred correctly but I'm having trouble with making a fetch call and appending the files to the formData (see the screenshot using fastify multipart). It throws an error in regards to not using a Blob. In my old approach (without using fastify) It seems that files[i].data holds the Buffer data which might be of type File which is allowed in the append method, but with Fastify I'm having trouble because the structure of the variable of files returned from .saveRequestFiles or when using parts is different.
I have been struggling with this issue for a while now and I'd appreciate the help.
Note: To understand exactly what I'm trying to do please check this doc on uploading files to Shopify: https://shopify.dev/docs/apps/online-store/media/products#step-2-add-media-to-a-product
Upvotes: 0
Views: 651
Reputation: 12890
files[i].file
does not exist.files[i].file
is a consumed readable stream, so you can't access it anymoreSo if the saveRequestFiles()
is used, it is needed to read the files[i].filepath
to create a new Readable stream.
Upvotes: 0