fileCreate mutation fails when given a originalSource from a stagedUpload

I have a flow for uploading videos where:

For the originalSource url, I provide the resourceUrl that comes from the stageUpload mutation.

The issue is that if I also give a filename to fileCreate, it throws an exception with the following message:

[{"field":["files","0","filename"],"message":"Provided filename extension must match original source."}] 

I triple checked, I do indeed specify the correct extension. What I suspect happens is that the code checks the extension in the filename against the resourceUrl value (this is just an assumption). If that’s the case, then it will never be a match since that url looks like: https://shopify-video-production-core-originals.storage.googleapis.com?external_video_id=<someId>

I can indeed specify the fileName through the stagedUpload mutation, and then it looks as expected in Shopify. BUT, I found this interaction and I think it’s not right

Hi Stefan,

If you don’t include the fileName in the fileCreate mutation, and just use the originalSource field, will this work?

Hi! Yes, it works. However, the error message from FileCreate could be misleading and can waste some time (it did for me). If it indeed matches the fileName against the stage URL (which has the pattern specified), without checking what file was actually updated at that URL, then the error message is misleading.

It should either:

  • check what file was uploaded: get actual data from stageUpladCreate
  • throw a different error message: (cannot specify a fileName when providing a stagedUploadUrl)

This is great feedback re: the error message, will pass this on to the team

For now, if you omit the file name can you progress with your app?

1 Like