Skip to content

Instantly share code, notes, and snippets.

@Ansh-Rathod
Last active October 18, 2021 13:28
Show Gist options
  • Save Ansh-Rathod/e5067098394b90d550c37304bb5ed96a to your computer and use it in GitHub Desktop.
Save Ansh-Rathod/e5067098394b90d550c37304bb5ed96a to your computer and use it in GitHub Desktop.
// 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