簡體   English   中英

Firebase 擴展“Resize Images”完成后是否有辦法獲得反饋? - Flutter Firebase 存儲

[英]Is there a way to get a feedback from the Firebase extension "Resize Images" once it is completed? - Flutter Firebase Storage

我面臨以下問題:

  1. 我將圖像上傳到 Firebase 存儲
//Start the upload
await StorageHandler.instance.uploadTask(mediaIDPath, largeFile);
  1. 上傳完成后,將觸發 Firebase 擴展“Resize Image”。 調整大小的圖像將單獨存儲在我的 FirebaseStorage 中的另一個路徑中

  2. 為了確保調整圖像大小,我在代碼中等待 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));
  1. 然后我正在獲取調整大小后的圖像的 URL。 我需要立即下載 URL,以便在調整圖像大小並添加到我在第 2 點中提到的其他路徑后立即在 GridView 中顯示圖像。
//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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM