NodeJS 服务器端 Firebase 存储的安全外部链接
Secure external links for Firebase Storage on NodeJS server-side
我在为存储在我的 Firebase 存储桶中的文件生成外部 link 时遇到问题。
我使用 Google Cloud Storage 有一段时间了,并使用 this library (which is based on this answer) 为常规存储桶生成外部 links,但在 Firebase 上使用它-分配的存储桶似乎不起作用。
我无法生成任何安全的 HTTPS links,并且不断收到证书验证错误 NET::ERR_CERT_COMMON_NAME_INVALID
,指出我的连接不是私有的。如果我从 HTTPS 中删除 'S',则 link 有效。
注意: 使用相同的凭据和私钥为我项目中的其他存储桶生成 links,效果很好。只有 Firebase 存储桶拒绝接受我的签名...
我推荐使用官方GCloud client, and then you can use 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
});
});
根据 这似乎适用于 Firebase 和 GCS 存储桶。
我在为存储在我的 Firebase 存储桶中的文件生成外部 link 时遇到问题。
我使用 Google Cloud Storage 有一段时间了,并使用 this library (which is based on this answer) 为常规存储桶生成外部 links,但在 Firebase 上使用它-分配的存储桶似乎不起作用。
我无法生成任何安全的 HTTPS links,并且不断收到证书验证错误 NET::ERR_CERT_COMMON_NAME_INVALID
,指出我的连接不是私有的。如果我从 HTTPS 中删除 'S',则 link 有效。
注意: 使用相同的凭据和私钥为我项目中的其他存储桶生成 links,效果很好。只有 Firebase 存储桶拒绝接受我的签名...
我推荐使用官方GCloud client, and then you can use 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
});
});
根据