簡體   English   中英

Firebase onFinalize 不會觸發函數模擬器

[英]Firebase onFinalize doesn't trigger for functions emulator

我正在為本地開發設置環境,只是測試模擬器是否正常工作,但我的簡單測試失敗且沒有任何錯誤。

// functions/index.js
exports.pdftoimg = functions.storage.object().onFinalize(async (object) => {
  console.log({ object });
});

模擬器啟動沒有問題:

firebase emulators:start
i  emulators: Starting emulators: auth, functions, firestore, hosting, pubsub, storage
✔  functions: Using node@16 from host.
i  hosting: Serving hosting files from: dist
✔  hosting: Local server: http://localhost:5002
i  functions: Watching "/Users/xxx/Code/myApp/functions" for Cloud Functions...
✔  functions[us-central1-pdftoimg]: storage function initialized.

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://localhost:4000                │
└─────────────────────────────────────────────────────────────┘

但是,當我使用 UI (http://localhost:4000/storage/default-bucket) 將測試 pdf 文件上傳到存儲模擬器時,日志中不會顯示任何內容。

我測試了 Firestore Db 的雲觸發器,但這似乎有效。

我錯過了什么?

謝謝

我可以看到您正在觸發 Cloud Function on Cloud Storage Changes返回上傳的object 元數據

但是,這個 function 沒有上傳文件:

onFinalize在桶中成功創建新的 object(或現有對象的新一代)時發送。 這包括復制或重寫現有的 object。 上傳失敗不會觸發此事件。

在這種情況下,請遵循提供給Upload Files的文檔。 最后,在您的代碼中添加錯誤處理將在下次幫助您,因為在這種情況下,您沒有日志或任何東西來調試錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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