[英]Is there a way to get a feedback from the Firebase extension "Resize Images" once it is completed? - Flutter Firebase Storage
我面臨以下問題:
//Start the upload
await StorageHandler.instance.uploadTask(mediaIDPath, largeFile);
上傳完成后,將觸發 Firebase 擴展“Resize Image”。 調整大小的圖像將單獨存儲在我的 FirebaseStorage 中的另一個路徑中
為了確保調整圖像大小,我在代碼中等待 4 秒(這不是解決此問題的正確方法)
//Start the upload
await StorageHandler.instance.uploadTask(mediaIDPath, largeFile);
//After the upload is completed, wait 4 seconds until the image is resized
await Future.delayed(Duration(seconds: 4));
//Start the upload
await StorageHandler.instance.uploadTask(mediaIDPath, largeFile);
//After the upload is completed, wait 4 seconds until the image is resized
await Future.delayed(Duration(seconds: 4));
//fetch the imageURL of the resized Image
gridURL = await StorageHandler.instance.getImageURLFromStorage(mediaIDPathResizedFile);
等待 4 秒不是正確的方法。 因此,我正在尋求從存儲中獲得調整大小已完成的反饋的可能性,以便我可以在之后獲取下載 URL。 我在 Firebase 中找不到任何提供此功能的方法。
重要說明:我不想在客戶端調整圖像大小以避免更多上傳操作並將 firebase 成本保持在最低水平!
有沒有人有解決方法的想法,以避免在我的情況下等待 4 秒?
我希望我足夠清楚地解釋我的問題,並期待有用的建議。
調整圖像大小擴展中沒有內置任何內容來向調用客戶端發出完成信號。
自己實現這一點的典型方法是創建一個Cloud Function , 當文件寫入 Cloud Storage 時觸發,如果文件是縮略圖,則向調用客戶端發送信號(例如,通過將信息存儲在關於如何到達客戶端的文件的元數據)通過 FCM 或 Firebase 的數據庫之一(實時數據庫或 Cloud Firestore)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.