Last active
October 18, 2021 13:28
-
-
Save Ansh-Rathod/e5067098394b90d550c37304bb5ed96a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://pub.dev/packages/file_picker | |
import 'package:file_picker/file_picker.dart'; | |
getMultipalFiles() async { | |
FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true); | |
List<File> files = []; | |
if (result != null) { | |
files = result.paths.map((path) => File(path)).toList(); | |
} else { | |
// User canceled the picker | |
} | |
List<String> downloadUrls= []; | |
for var img in files{ | |
var url = await _uploadFile(img,"folder path"); | |
downloadUrls.add(url); | |
} | |
} | |
Future<String> _uploadFile(File file,String folderName) async { | |
final ref = | |
FirebaseStorage.instance.ref().child(folderName).child(file); | |
UploadTask uploadTask = ref.putFile(file); | |
TaskSnapshot taskSnapshot = await uploadTask.whenComplete(() => {}); | |
String videoUrl = await taskSnapshot.ref.getDownloadURL(); | |
return videoUrl; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment