從云函數(shù)上傳的Firebase文件中獲取下載URL在Firebase存儲中上傳了一個具有Firebase功能的文件之后,我想獲得該文件的下載網(wǎng)址。我有這個:...return bucket .upload(fromFilePath, {destination: toFilePath})
.then((err, file) => {
// Get the download url of file
});對象文件有很多參數(shù)。甚至有一個叫mediaLink..但是,如果我試圖訪問該鏈接,則會得到以下錯誤:匿名用戶沒有storage.objects.get訪問對象.。有人能告訴我如何獲得公開下載網(wǎng)址嗎?謝謝
3 回答

汪汪一只貓
TA貢獻1898條經(jīng)驗 獲得超8個贊
const gcs = require('@google-cloud/storage')({keyFilename: 'service-account.json'}); // ...const bucket = gcs.bucket(bucket);const file = bucket.file(fileName);return file.getSignedUrl({ action: 'read', expires: '03-09-2491'}).then(signedUrls => { // signedUrls[0] contains the file's public URL});
@google-cloud/storage
更新
在SDK中有一個特殊的服務(wù)帳戶,通常是通過第二個非默認實例。 或者,如果沒有服務(wù)帳戶,則通過授予默認AppEngine服務(wù)帳戶“signBlob”權(quán)限。
- 3 回答
- 0 關(guān)注
- 766 瀏覽
添加回答
舉報
0/150
提交
取消