What’s the best solution to download an image file from a url in retool mobile? I tried utils.downloadFile(), but it seems it doesn’t support urls.
Reading a lot on this forum. Do I need a resource to retrieve an image somehow? How does that work?
What’s the best solution to download an image file from a url in retool mobile? I tried utils.downloadFile(), but it seems it doesn’t support urls.
Reading a lot on this forum. Do I need a resource to retrieve an image somehow? How does that work?
Hi @Steven_W, to do this we can just create a REST API resource to get the image first:
Here is my query that gets the image:
We can then use @joeBumbaca's solution to take care of the rest:
That should work. However, there seems to be a bug with the utils.downloadFile
on our current cloud version (3.66.0). If you are on Self-hosted Retool, it should work on older versions. I tested it on 3.33-stable and it worked.
We have an existing bug report for this issue, I added our experience to it. We'll update you here when it's fixed
let barcode = getBarcodeImage.data.base64Data;
utils.downloadFile({base64Data:barcode},'test', 'gif');
I did manage to retrieve the base64data. utils.downloadFile runs succesfully. But nothing is being downloaded. Seems you are right that there is a bug. there's no way I can find out if this actually works.
Is there are thread about this bug? I would like to read it
Yes, let me link you to the current issue:
The thread is long because it first happened about a year ago. Although it was fixed, it looks like there was a regression around Feb 17th.
Update: This issue is fixed but the following has changed:
This syntax does not work anymore:
let file = query2.data
utils.downloadFile({base64Data: file.base64Data}, "cat", "jpeg")
// won't work
Instead, take this approach:
let file = query2.data
utils.downloadFile(file.base64Data, "cat", "jpeg")
// or utils.downloadFile({base64Binary: file.base64Data}, "cat", "jpeg")
// works like a charm!