是否可以在 Flutter 的 firebase 集合中上傳 pdf。如何從firebase下載pdf
uj5u.com熱心網友回復:
Firebase 實時資料庫或 Firebase Cloud Firestore 不能托管任何檔案。但 Firebase 有一個名為Cloud Storage的產品,它可以托管檔案并在您的 Cloud Firestore 中實際保留對它的參考。
您需要做的是首先上傳檔案,然后獲取它的 URL 并將其保存在您的 Cloud Firestore 中:
Future<String> uploadFile(String filePath) async {
File file = File(filePath);
try {
await firebase_storage.FirebaseStorage.instance
.ref('uploads/bills.pdf')
.putFile(file);
String downloadURL = await firebase_storage.FirebaseStorage.instance
.ref('uploads/bills.pdf')
.getDownloadURL();
return downloadUrl;
} on firebase_core.FirebaseException catch (e) {
print(e);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/439362.html
下一篇:下劃線串列平鋪
