下载的服务帐户文件在谷歌云存储使用签署网址 [英] Downloading file with service account using signed url in Google Cloud Storage

查看:363
本文介绍了下载的服务帐户文件在谷歌云存储使用签署网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是产生签订网址为驱动器上传文件
  将与客户端共享,以便他们可以能够下载
  文件的形式驱动,无需身份验证。

My Requirement is to generate signed Url for drive uploaded document which will be shared with clients so that they can able to download files form drive without any authentication.

作为新手使用驱动器API的第一次,我使用.NET库调用驱动API。我已经安装的文件中提到的服务帐户谷歌API。我能够使用服务帐户,并能上传文件API调用。我向下文称<一个href=\"http://stackoverflow.com/questions/26354609/how-to-sign-url-in-net-for-google-cloud-storage][1]\">How登录网址.NET中的谷歌云存储创建符号链接。但在访问中提到的网址收到以下错误后:

As newbie to use drive API for first time, I am using .NET libraries to call drive API. I have setup the service account for Google API as mentioned in the document. I am able to make API call using service account and able to upload the files. I reffered to How to sign url in .net for google cloud storage to create the sign url. but after accessing the mentioned url receiving following error:

 <Error> <Code>InvalidBucketName</Code> <Message>The specified bucket
 is not valid.</Message> </Error>

我不知道GoogleBucketName和GoogleBucketDir。谁能告诉我在哪里,我会得到GoogleBucketName&安培; GoogleBucketDir。目前,我设置GoogleBucketName到Prject名字,我在谷歌开发者控制台创建 https://console.developers.google.com/ 并GoogleBucketDir为空字符串。先谢谢了。

I am not sure about GoogleBucketName and GoogleBucketDir. Can anybody tell me where i would get GoogleBucketName & GoogleBucketDir. Currently i am setting GoogleBucketName to Prject Name i created in google developer console https://console.developers.google.com/ and GoogleBucketDir as empty string. Thanks in advance.

推荐答案

您上传您返回的文件资源

文件资源包含一个称为字段 alternatelink

File resource contains a field called alternatelink

alternateLink结果字符串结果的链接在相关谷歌打开文件
  编辑器或浏览器。

alternateLink
string
A link for opening the file in a relevant Google editor or viewer.

您可以与其他用户共享此链接,他们将能够在驱动中打开该文件,他们也应该能够从驱动器下载。

You can share this link with other users they will be able to open the file in drive they should also be able to download it from drive.

有一个名为另一个领域 downloadUrl 这可能让他们下载它,但我还没有测试,一个个人。如果我没有记错 downloadUrl 为空有时候,所以我没有使用它。

There is another field called downloadUrl which might let them download it but I haven't tested that one personal. If I remember correctly downloadUrl was null sometimes so I didn't use it.

Console.WriteLine("Alternate link: " + item.AlternateLink);  

谷歌云端硬盘API链接到文件教程

这篇关于下载的服务帐户文件在谷歌云存储使用签署网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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