jbb*_*jbb 3 google-cloud-storage firebase-storage
我正在将带有 firebase 存储的文件上传到 some/path/file.txt 稍后我会得到一个下载网址并通过浏览器中的链接提供下载。当用户下载该文件时,该文件被命名为 file.txt
现在我通过 gcloud storage 使用云函数修改这个文件。我重新上传它:
bucket.upload(localfile, {destination: 'some/path/file.txt'});
Run Code Online (Sandbox Code Playgroud)
现在,当用户下载文件时,浏览器中的建议文件名是:some%2path%2file.txt
有办法避免这种情况吗?
是的,将Content-Disposition文件的标题设置为仅包含file.txt. 就像是:
bucket.upload(localFile, {
destination: 'some/path/file.txt'
metadata: {
contentDisposition: 'attachment; filename="file.txt"'
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2105 次 |
| 最近记录: |