如何生成对上传到Firebase存储的文件的访问令牌? [英] How can I generate access token to file uploaded to firebase storage?
问题描述
我可以使用firebase-admin通过nodejs将文件上传到我的Firebase存储桶,但是当我进入Firebase UI时,无法打开文件.我注意到通过firebase UI上传的文件将自动生成一个访问令牌,但是对于通过nodejs上传的文件则没有.
I'm able to upload a file to my firebase storage bucket via nodejs using the firebase-admin but when I go to the firebase UI I cannot open the file. I noticed that uploaded files via firebase UI will have an access token automatically generated but no for files uploaded via nodejs.
我已经尝试了多种方法,例如设置带有下载令牌的元数据,以及在文件上传后将其公开.没有一个工作.
I already tried several things like setting metadata with downloadtokens and making the file public after it is uploaded. None has worked.
如何通过API调用生成访问令牌,而不必转到hi并单击为每个上传的文件生成令牌?
How can I generate the access token via API call rather than having to go to hi and click generate token for each uploaded file?
推荐答案
我使用以下命令,它运行正常
I use the below command and it is working perfectly
const uuidv4 = require('uuid/v4');
const uuid = uuidv4();
metadata: { firebaseStorageDownloadTokens: uuid }
这篇关于如何生成对上传到Firebase存储的文件的访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!