gpt4 book ai didi

node.js - NodeJS 服务器端 Firebase 存储的安全外部链接

转载 作者:太空宇宙 更新时间:2023-11-03 22:52:27 25 4
gpt4 key购买 nike

我在生成指向 Firebase 存储桶中存储的文件的外部链接时遇到问题。

我使用 Google Cloud Storage 一段时间了,并使用过 this用于为常规存储桶生成外部链接的库(基于 this 答案),但在 Firebase 分配的存储桶上使用它似乎不起作用。

我无法生成任何安全的 HTTPS 链接,并且不断收到证书验证错误 NET::ERR_CERT_COMMON_NAME_INVALID,表明我的连接不是私有(private)的。如果我从 HTTPS 中删除“S”,该链接就可以工作。

注意:使用相同的凭据和私钥为我的项目中的其他存储桶生成链接,效果很好。只有 Firebase 存储桶拒绝接受我的签名...

最佳答案

我推荐使用官方GCloud client ,然后您可以使用 getSignedUrl()获取文件的下载 URL,如下所示:

bucket.file(filename).getSignedUrl({
action: 'read',
expires: '03-17-2025'
}, function(err, url) {
if (err) {
console.error(err);
return;
}

// The file is now available to read from this URL.
request(url, function(err, resp) {
// resp.statusCode = 200
});
});

Generate Download URL After Successful Upload这似乎适用于 Firebase 和 GCS 存储桶。

关于node.js - NodeJS 服务器端 Firebase 存储的安全外部链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37868485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com