问题
I have seen several examples regarding uploading a document in firebase storage but there is no document of downloading a list of files from firebase storage to flutter. On Firebase docs, there is a lot of documentation on firebase storage for Android, iOS, web, c++ etc. but not flutter. Specially if I Talk about Video's
VideoPlayerController videoPlayerController;
@override
void initState() {
videoPlayerController = VideoPlayerController.network('/* Download Url*/');
super.initState();
}
Video's needs Url in the initialization of the app
回答1:
To find an example of uploading and downloading file to Cloud Storage from Flutter, have a look at the example application of the FlutterFire library firebase_storage
.
The process mostly consists of getting a download URL, which gives you read-only access to the file:
final String url = await ref.getDownloadURL();
And then loading the data from that URL with:
final http.Response downloadData = await http.get(url);
Check out the _downloadFile method for the full example.
来源:https://stackoverflow.com/questions/56610221/downloading-files-from-firebase-storage-to-flutter