My Javascript Webapp enables logged-in users to upload PDF files into the Google Cloud and store them in a Cloud Storage bucket. I'd like the wider public to be able to view the files they've just uploaded, but this is proving more difficult than I expected.
An HTML button firing an onclick function for a window.open call hard-coded with an HREF referencing the full Cloud Storage URL for the file together with an access token does the trick. I can get this information from the Storage tab in the Firebase console, but I'm at a loss to find a way of configuring this arrangement dynamically.
The URL part doesn't seem to be a problem, but I would appreciate advice on how I can obtain a suitable access token.
Alternatively, can anyone suggest how I might lower the bar on GCP security settings for my Cloud Storage files so that a casual user doesn't need a token in the first place? I have tried using the Cloud Security console to set permissions but have still to find a combination of settings that gives the desired outcome.
The answer is provided by Google's Make data public document.
This tells you how to make either individual files or the entire content of a bucket publicly readable.
In my case, the second approach was clearly what I needed. I created a new bucket specifically for the content I wanted to share and followed the instructions closely - they're complex and easily misunderstood. At several points, you need to select settings from drop-down lists but, while these lists are populated, you don't see the items you're looking for until you start typing in the keywords detailed in the instructions.
With the new permission in place, my files were accessible by URLs of the form https://storage.googleapis.com/[Bucket name]/[File name]