我正在将带有 firebase 存储的文件上传到 some/path/file.txt 后来我得到一个下载 url 并通过浏览器中的链接提供下载。当用户下载文件时,它被命名为 file.txt
现在我通过 gcloud 存储使用云功能修改此文件。我重新上传它:
bucket.upload(localfile, {destination: 'some/path/file.txt'});
现在当用户下载文件时,浏览器中建议的文件名是:some%2path%2file.txt
有没有办法避免这种情况?
是的,将Content-Disposition
文件的标题设置为仅包含file.txt
. 就像是:
bucket.upload(localFile, {
destination: 'some/path/file.txt'
metadata: {
contentDisposition: 'attachment; filename="file.txt"'
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句