Google云端存储:下载其他名称的文件 [英] Google Cloud Storage: download a file with a different name

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

问题描述

我想知道是否可以从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.

例如,我在Google Cloud Storage中存储了一个名为123-file.txt的文件,但是当我下载该文件时,我想选择一个不同的名称,例如file.txt

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

我注意到下载链接如下: https://storage.cloud .google.com/bucket_name%2F123-file.txt?response-content-disposition =附件;%20filename = 123-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

因此,我尝试将其更改为: https://storage.cloud.google .com/bucket_name%2F123-file.txt?response-content-disposition =附件;%20filename = 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

但是它仍然继续以123-file.txt而不是file.txt下载

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

推荐答案

response-content-disposition参数只能由授权请求使用.匿名链接不起作用.您有几种选择:

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. 特定对象的内容处置是其元数据的一部分,可以永久设置.如果您始终希望使用特定名称下载特定文件,则可以永久设置该对象的内容处置元数据.

  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.

您还可以生成包含response-content-disposition查询参数的签名URL.然后,用户将提出授权请求以下载资源.

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云端存储:下载其他名称的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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