Flutter Firebase Multiple File Upload

Flutter Firebase Multiple File Upload :

This flutter tutorial post is upload file in firebase, cloud storage.

Install the plugin firebase_storage :

dependencies:
firebase_storage:

StorageMetadata :

1) Content-Type : The content type (MIME type) of the StorageReference.
2) Cache-Control, Content-Disposition, Content-Encoding, Content-Language and CustomMetaData.

set the permission in firebase :

Firebase right side menu click Storage. This below lines set Rules.

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}
Flutter Firebase Multiple File Upload
List<StorageUploadTask> _tasks;

//for loop code
String path = multipleUpload.file.path;
var filename = path.split("/").last;
upload(filename, path);

//Single or Multiple flie upload firebase
  upload(fileName, filePath) async {
    _tasks = <StorageUploadTask>[];
    StorageReference storageRef =
        FirebaseStorage.instance.ref().child(fileName);
    final StorageUploadTask uploadTask = storageRef.putFile(File(filePath));
    _tasks.add(uploadTask);
    await uploadTask.onComplete;
    if (uploadTask.isComplete) {
      _tasks.forEach((StorageUploadTask task) async {
        final String url = await task.lastSnapshot.ref.getDownloadURL();
        print('Tag' + url);
      });
    }
  }

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in