I’m Developing an order admin ui block extension and I want to have an admin block extension with a button to download a file stored in the store’s files (the file is hosted on the Shopify CDN).
It looks like you’ve run into a bit of an edge case with the download feature on the Button. If you’re serving the file yourself, you can explicitly set the Content-Disposition': 'attachment' header on the response, but when you’re using a file from the store’s files, the request is cross-origin and that header is not set explicitly. The solution is to use the attachment query param to force the link to download.
Just add it to your URL like this: https://cdn.shopify.com/s/files/1/0916/8722/3587/files/123-2.png?v=1737458814&attachment.
I’ll add a note to the Button docs to make things easier for folks who run into this in the future!
Hi @Elana ,
Thank you, it worked!
But, I uploaded a PNG file and it downloaded a WEBP file.
I understand the convertion for better performace but I really do need the original PNG image. I saw in a community thread that you can pass a format query param but that doesn’t seem to work (even without the attachment param).
Is still still supported? Is there a way for me to get the image back in the original PNG format?
I tried to pass a filename with a png extension to the “download” prop but it didn’t work (and actually doesn’t seem to even change the filename itself regardless of the format)
Sorry for the delayed response! It doesn’t look like we support the format param any longer, but I am able to download in the original format, both manually from the files section and with a url in the block extension. Is this the method you’re using?