Shopify fileCreateMutation with Blob url as source

Hi all, I have a Polaris drag and drop / add image element on my jsx page. I am saving the bloburl and filename as params. When a customer clicks the button to add, it passes the information and triggers a create.js function in where I want to create the image in Shopify via a fileCreateMutation. However when using the bloburl as the source, shopify sees it (off course) as an html element, while the filename for the image will be in a png format. How can I change the bloburl into a source that shopify can consume (I believe base64, but not sure how to). Attached the part of the code for create.js and page.jsx in case it might help. Thanks in advance! Bas
1 Reply
Chocci_Milk
Chocci_Milk8mo ago
Hello, I would recommend one of two things. You either add a route and accept the file in its entirety using fastify/multipart and then call the 2 Shopify GraphQL endpoints required to make a file upload or you save the file to your database using the built in file upload functionality, then use the action runtime to call the same GraphQL endpoints. That way you will either have a src url that you can share with them (Gadget file way) or the file to upload itself

Did you find this page helpful?