Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(storage): updated the ContentType documentation for the signedUrl in the storage package #11306

Closed

Conversation

blagoySimandov
Copy link

Updated the documentation for the ContentType field in the SignedURLOptions struct in the storage package, to correctly
state that the field is required.

Motivation: Issue #11305

@blagoySimandov blagoySimandov requested review from a team as code owners December 18, 2024 00:54
Copy link

google-cla bot commented Dec 18, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@blagoySimandov blagoySimandov changed the title Updated the ContentType documentation for the signedUrl in the storage package fix(storage): Updated the ContentType documentation for the signedUrl in the storage package Dec 18, 2024
@blagoySimandov blagoySimandov changed the title fix(storage): Updated the ContentType documentation for the signedUrl in the storage package fix(storage): updated the ContentType documentation for the signedUrl in the storage package Dec 18, 2024
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Dec 18, 2024
@@ -475,7 +475,7 @@ type SignedURLOptions struct {

// ContentType is the content type header the client must provide
// to use the generated signed URL.
// Optional.
// Required.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not really accurate. It's valid to generate a URL without a Content-Type header (e.g. for a GET request), so the field is definitely not required in SignedURLOptions.

Moreover from the docs (https://cloud.google.com/storage/docs/authentication/canonical-requests#about-headers) it sounds like content-type is not a required canonical header, so you should be able to add it to the request after signing.

Maybe there is a server side issue here? Let me know if you think I'm mistaken, or you can file an issue with support to share details about the error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just believe it's misleading... I imagined that omitting the ContentType would make it so it accepts any kind of content type, this in fact was not the case and the only accepted content type was that of an empty string... Not to mention the fact that in a client-side/browser setting if you omit the content-type from the header the browser will automatically put in a "guess" for the content-type of the file that you are uploading, which would then be rejected since the only accepted content type would be ""... Results in a really nasty bug..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is something i wrote quite a while ago that might help you understand my frustration. blog

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so I investigated this further and it looks like you are using v2 signing, while the docs I linked to are for v4.

We recommend v4 signing generally and it does something more like what you want (at least according to the docs). Can you try that out by setting https://pkg.go.dev/cloud.google.com/go/storage#SignedURLOptions.Scheme ?

I think we could improve the docs here for v2, but I would definitely not want to mark this field as required in any case since it is not required for most signed URLs.

@tritone tritone changed the title fix(storage): updated the ContentType documentation for the signedUrl in the storage package doc(storage): updated the ContentType documentation for the signedUrl in the storage package Dec 18, 2024
@tritone tritone closed this Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants