Я работаю над приложением Flutter и хочу загрузить файлы PDF в хранилище Firebase,
Я выбираю файл с помощью documents_picker, но не могу загрузить его в хранилище ... пожалуйста, помогите мне в этом ... мой код ниже
uploaddoc()async{
dynamic docPaths;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
docPaths = await DocumentsPicker.pickDocuments;
final Directory tempDir = Directory.systemTemp;
final String fileName = "${Random().nextInt(10000)}.pdf";
final File file = File('${tempDir.path}/$fileName');
file.writeAsBytesSync(docPaths);
final StorageReference ref = FirebaseStorage.instance.ref().child(fileName);
final StorageUploadTask task = ref.putFile(file);
final Uri downloadUrl = (await task.future).downloadUrl;
_path = downloadUrl.toString();
print(_path);
} on PlatformException {
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted)
return;
setState(() {
_platformVersion = docPaths.toString();
});
}