Back

Storage file download with Flutter on web

  • 0
  • Flutter
  • Storage
LaurentLP
9 Oct, 2023, 12:41

Hey, I'm developping a Flutter web app and I used the Storage service to upload files (pdf, jpg, png). I am having troubles to download these files because the documentation example is probably designed for mobile Flutter apps. After a bit of research I am implementing the file download with a method executing this code : (with 'dart:html' as html)

html.window.open('http://localhost/v1/storage/buckets/$BUCKET_ID/files/$FILE_ID/download?project=$APPWRITE_PROJECT_CUSTOM_ID&mode=admin', "Download");

I have the feeling that it is not the recommended and safest way of doing it, but I could not find any other one. Could you please tell me how I could properly implement it? Thanks in advance,

TL;DR
I'm developing a Flutter web app and I'm having trouble downloading files uploaded using the Storage service. I tried using the `html.window.open()` method, but I'm not sure if it's the recommended way. Is there a proper way to implement file downloading in Flutter web? Solution: It seems that Flutter web can be a bit hacky. You can either use the `html.window.open()` method as you've done or call the download method using the SDK. Here's a helpful Stack Overflow post on downloading files in Flutter web: https://stackoverflow.com/questions/65431345/flutter-web-download-file-from-url-instead-of-opening-it
Drake
9 Oct, 2023, 13:32

Btw, you shouldn't use mode=admin in your app.

It seems flutter web is hacky in general. You can do it the way you've done or you can call the download method using the SDK and then do something like this: https://stackoverflow.com/questions/65431345/flutter-web-download-file-from-url-instead-of-opening-it

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more