File.publicUrl() returns an incorrect URL if the file key contains URL query parameters
See original GitHub issueEnvironment details
- OS: Google Cloud Function (1st gen)
- Node.js version: 14.19.1
- npm version:
@google-cloud/storage
version: 5.8.5
Steps to reproduce
- Upload a file to Cloud Storage containing query parameters in the key – example:
somefile.jpg?state=thumbnail
- Make the file public via
File.makePublic()
- Retrieve the file’s public URL with
File.publicUrl()
The returned URL looks like https://storage.googleapis.com/bucket/somefile?state=thumbnail
but any attempt to download the file at that URL results in the following error:
<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.</Details>
</Error>
HOWEVER Viewing the file in the Google Cloud Platform Cloud Storage web console does give the correctly-encoded URL which looks like https://storage.googleapis.com/bucket/somefile.jpg%3Fstate%3Dthumbnail
I’ve reviewed the Changelog for subsequent releases but there is no mention of a fix for this.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
A Beginner's Guide to URL Parameters - Semrush
In this comprehensive guide, we explore the ins and outs of URL parameters. Discover now how to use query strings without hurting your ......
Read more >Google Cloud Storage public link does not become invalid ...
When Your sharing Publicly Url is like https://storage.googleapis.com/bucket_name/pictureName. If you delete the file or uncheck the Share ...
Read more >Filter a report using query string parameters in the URL
You want to create a report that has links to other Power BI reports, but you want to show only some of the...
Read more >A guide to Firebase Storage download URLs and tokens
A Firebase download URL is a long-lived, publicly accessible URL that is used to access a file from Cloud Storage. The download URL...
Read more >About URL parameters - Google Ads Help
URL parameter is a way to pass information about a click through its URL. You can insert URL parameters into your URLs so...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @sseppola it was intentional from the standpoint that other spots in the code are currently encoding the entire name portion as I applied in the fix. Your suggestion makes sense to me, let me investigate if switching to something like this will have any other possible consequences.
Makes sense, thanks for resolving it so quickly 👍