0

I have created a service using :

storage.Client(project='project_name', credentials=credentials)

https://googleapis.dev/python/storage/latest/client.html

And I'm able to upload, delete and list the files in a users Google Cloud bucket. I've seen an option to download the file to a server, but is there any option to get a downloadable link?

Any help will be truly appreciated. Thanks.

Jamie
  • 1,530
  • 1
  • 19
  • 35
subin_john_
  • 23
  • 1
  • 7
  • 1
    https://googleapis.dev/python/storage/latest/blobs.html#google.cloud.storage.blob.Blob.generate_signed_url ? – h4z3 Jan 30 '20 at 10:05
  • Using that I am able to get a signed url for files in my cloud bucket, what I am trying is to get a download url for files in another cloud bucket. – subin_john_ Jan 30 '20 at 10:38
  • You can actually make up the url for downloading, as mentioned in this [post](https://stackoverflow.com/questions/20478369/how-do-you-get-or-generate-a-url-to-the-object-in-a-bucket). The structure will need to be as follows: `http://BUCKET_NAME.storage.googleapis.com/OBJECT_NAME`. The objects or files in the bucket must be readable by anonymous users, or else the download will fail. I hope it helps. – Christopher Rodriguez Conde Jan 30 '20 at 11:21
  • I am looking to download files without the condition "must be readable by anonymous user(Public access type - Not public) – subin_john_ Jan 30 '20 at 11:45
  • If it is the case you only want the user to be able to access them without the condition "must be readable by anonymous user, you can generate a signed URL that will allow only the holder of the URL to download the object. You could use one of the [GCS libraries](https://developers.google.com/storage/docs/accesscontrol#Signed-URLs) to do it. I hope it helps. – Christopher Rodriguez Conde Jan 31 '20 at 10:12
  • What I want is to get downloadUrl for files in a users Google Cloud bucket using the credentials got after the user authentication. I am able to create a signed url for files in my bucket using the service account file created in the same account. Is there any option similar to AWS where we can create a signed url for files in a another persons bucket using the authentication token. – subin_john_ Jan 31 '20 at 11:39

0 Answers0