K20GH
K20GH

Reputation: 6281

Get a permanent URL from Google Cloud Storage?

I have a scenario where a user can upload images to Firebase Storage, however I do not want them to be able to get a URL for these images (Copy Image Address). Instead I want to provide them with a blob.

When a user uploads the image client side, I get the download URL and store that in Firestore. When the user wants to see the image, I have a cloud function that downloads that image, and sends it to the user as a blob.

This works great for images the user uploads, however I also have a cloud function that is triggered automatically when an image is uploaded and generates a thumbnail.

How do I go about getting a permanent download URL from a Cloud Function/Node server for this generated image? I can get a signed one, but it's not what I need

Upvotes: 2

Views: 2593

Answers (3)

Phillip Kigenyi
Phillip Kigenyi

Reputation: 1489

If you are using Django and django-storages[google] lib

  1. Make the bucket public(not advisable for production)
  2. Disable ACL and URL signing

Add these to the settings.py

GS_DEFAULT_ACL = None
GS_QUERYSTRING_AUTH = False

Upvotes: 0

Harif Velarde
Harif Velarde

Reputation: 753

If you want a permanent URL to access your data, you could make them public according to this documentation[1].

Just keep in mind that when accessing public data through the Google Cloud Platform Console, you must authenticate with Google. It can be accessed with any Google account, the account does not have to be associated with the project that contains the public data, nor must it be registered in the Cloud Storage service [2].

[1] https://cloud.google.com/storage/docs/access-control/making-data-public

[2] https://cloud.google.com/storage/docs/access-public-data

Upvotes: 2

guillaume blaquiere
guillaume blaquiere

Reputation: 75920

You can't directly with Google Cloud Storage. The signed URL can't live more than 7 days

The longest expiration value is 604800 seconds (7days).

You can keep the link of the generated thumbnail image, but you have to either download it and serve it each time, or generate a signed url for using and displaying it, each time also. This second solution reduces the processing time and thus the cost.

Upvotes: 2

Related Questions