1

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.

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>

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.

Community
  • 1
  • 1
Sid159
  • 61
  • 5

1 Answers1

2

After you upload a file you are returned a file resource.

File resource contains a field called 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.

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);  

Google Drive API Link to file Tutorial

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Thanks for replay @dalmTo i know we can use alternatelink to download resource but when you open link in browser user will be asked to do sign in to download the document but as per my requirement i want to allow user without any authentication and that the reason why i am using service account there is something i am missing with bucket name how could i find bucket name? :( – Sid159 Oct 08 '15 at 05:21
  • Unfortunately this is your only option besides downloading the file useing the service account and letting them download from your sever. – Linda Lawton - DaImTo Oct 08 '15 at 05:27
  • Try setting the file to public then use the alternatelink. I have never had a problem with forcing login. However that being said most of my users have Google accounts – Linda Lawton - DaImTo Oct 08 '15 at 05:29
  • We can only create signed url of documents uploaded using google storage API not for documents uploaded through Google Drive API :( – Sid159 Oct 09 '15 at 05:05