Google Cloud Storage:下载具有不同名称的文件 [英] Google Cloud Storage: download a file with a different name

查看:15
本文介绍了Google Cloud Storage:下载具有不同名称的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm wondering if it's possible to download a file from Google Cloud Storage with a different name than the one that has in the bucket.

For example, in Google Cloud Storage I have stored a file named 123-file.txt but when I download it I would like choose a different name, let's say file.txt

I've noticed that the link for download it is like: https://storage.cloud.google.com/bucket_name%2F123-file.txt?response-content-disposition=attachment;%20filename=123-file.txt

So I've tried to change it to: https://storage.cloud.google.com/bucket_name%2F123-file.txt?response-content-disposition=attachment;%20filename=file.txt

But it still keeps downloading as 123-file.txt instead of file.txt

解决方案

The response-content-disposition parameter can only be used by authorized requests. Anonymous links don't work with it. You have a few options:

  1. The content-disposition of a particular object is part of its metadata and can be permanently set. If you always want a specific file to be downloaded with a specific name, you can just permanently set the content-disposition metadata for the object.

  2. You can also generate signed URLs that include the response-content-disposition query parameter. Then the users will be making authorized requests to download the resource.

这篇关于Google Cloud Storage:下载具有不同名称的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆