如何解决Firebase云存储:生成签名URL时,为什么要使用应用引擎的服务帐户?
我有一个快递服务器,该服务器生成用于文件上传的签名URL:
app.get("/signedurl/:filename",async (req,res,next) => {
const { filename } = req.params;
// These options will allow temporary uploading of the file with outgoing
// Content-Type: application/octet-stream header.
const options = {
version: "v4",action: "write",expires: Date.now() + 15 * 60 * 1000,// 15 minutes
contentType: "application/octet-stream",} as GetSignedUrlConfig;
// Get a v4 signed URL for uploading file
const [url] = await admin
.storage()
.bucket()
.file(filename)
.getSignedUrl(options);
res.json({ url });
});
服务器在firebase功能上运行。
由于在本地环境上进行测试时需要凭据文件,因此我将其部署并访问“ / signedurl / test”以生成测试文件的签名URL。
首先,日志显示错误:Identity and Access Management (IAM) API has not been used in project 794261759992 before or it is disabled.
,因此我启用了API。
然后日志显示错误:Error: Permission iam.serviceAccounts.signBlob is required to perform this operation on service account projects/[$my_project_id]/serviceAccounts/[$my_project_id]@appspot.gserviceaccount.com.
我知道如何添加权限,但是该服务帐户使我感到困惑。
我在Firebase控制台上看到,firebase的服务帐户就像“ firebase-adminsdk-xxxx @ [$ my_project_id] .iam.gserviceaccount.com”。
我认为错误中的服务帐户是针对App引擎的。 但是我什至没有使用App Engine。
那为什么要使用该服务帐户来进行签名?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。