-
Notifications
You must be signed in to change notification settings - Fork 812
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
blob/gcsblob: Ensure driver sets Content-Type auto-detection properly #3381
blob/gcsblob: Ensure driver sets Content-Type auto-detection properly #3381
Conversation
fff9db4
to
53a0705
Compare
@vangent I think the GCS tests need to be re-recorded to handle the I'm not sure why the Ubuntu test is failing with this, but macOS seems to want
I've regenerated the list on Linux and checked that in. |
Here's a diff between % diff new/ContentType_is_left_empty_if_not_provided_and_DisableContentTypeDetection_is_true.replay newpatch/ContentType_is_left_empty_if_not_provided_and_DisableContentTypeDetection_is_true.replay
2c2
< "Initial": "AQAAAA7dahh3OKHswP4g",
---
> "Initial": "AQAAAA7dahj1FFqpsP4g",
40c40
< "ID": "cbec847fefac6811",
---
> "ID": "d807be34f7fd3105",
71c71
< "695"
---
> "654"
77c77
< "Fri, 23 Feb 2024 04:39:20 GMT"
---
> "Fri, 23 Feb 2024 04:41:25 GMT"
80c80
< "CNHm0aXSwIQDEAE="
---
> "CLaBtuHSwIQDEAE="
96c96
< "ABPtcPrmZkac9Ivz6JM0oa_MRPdert1V6QDwMmYv14dyiVgjakwetkodrvUPogTCrU1XKdPApw"
---
> "ABPtcPpfV9FCLjT5Tf88GqdHuPQKdMKrAALRoYnHeBB7zxAMvPhaPNaqr4UUfOQNgtIY6KHDAeCSSFOBPQ"
99c99
< "Body": "eyJraW5kIjoic3RvcmFnZSNvYmplY3QiLCJpZCI6InN0YW5odS10ZXN0L2Jsb2ItZm9yLXJlYWRpbmcvMTcwODY2MzE2MDIwNjE2MSIsInNlbGZMaW5rIjoiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vc3RvcmFnZS92MS9iL3N0YW5odS10ZXN0L28vYmxvYi1mb3ItcmVhZGluZyIsIm1lZGlhTGluayI6Imh0dHBzOi8vc3RvcmFn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OTk1OCZhbHQ9bWVkaWEiLCJuYW1lIjoiYmxvYi1mb3ItcmVhZGluZyIsImJ1Y2tldCI6InN0YW5odS10ZXN0IiwiZ2VuZXJhdGlvbiI6IjE3MDg2NjMyODU1Nzk5NTgiLCJtZXRhZ2VuZXJhdGlvbiI6IjEiLCJzdG9yYWdlQ2xhc3MiOiJTVEFOREFSRCIsInNpemUiOiI2MzU0IiwibWQ1SGFzaCI6IkQycDhuL1BUMTNDNDkvb1p3cTRaMEE9PSIsImNyYzMyYyI6InRkd3JnUT09IiwiZXRhZyI6IkNMYUJ0dUhTd0lRREVBRT0iLCJ0aW1lQ3JlYXRlZCI6IjIwMjQtMDItMjNUMDQ6NDE6MjUuNjE1WiIsInVwZGF0ZWQiOiIyMDI0LTAyLTIzVDA0OjQxOjI1LjYxNVoiLCJ0aW1lU3RvcmFnZUNsYXNzVXBkYXRlZCI6IjIwMjQtMDItMjNUMDQ6NDE6MjUuNjE1WiJ9"
103c103
< "ID": "cde3e48f8ec60e44",
---
> "ID": "d6df0cec23facc54",
139c139
< "text/html; charset=utf-8"
---
> "application/octet-stream"
142c142
< "Fri, 23 Feb 2024 04:39:20 GMT"
---
> "Fri, 23 Feb 2024 04:41:25 GMT"
151c151
< "Fri, 23 Feb 2024 04:39:20 GMT"
---
> "Fri, 23 Feb 2024 04:41:25 GMT"
157c157
< "1708663160206161"
---
> "1708663285579958"
176c176
< "ABPtcPp9XU3hLfwVwoC1vJdjJn7zRorTQU2HOwTeCBzWVYLPRNjPJr345BBGYYhwF2L1NETKgQ"
---
> "ABPtcPrchhnqFBhXE0m-ouetvWbS7oum-Yb6fgfFr5SNHrAj7ZJHCXNWTSg10IEFyO-FwHihi_wxYRRDfw"
183c183
< "ID": "d020bd5d188ff050",
---
> "ID": "93892b86d06d0e26",
222c222
< "Fri, 23 Feb 2024 04:39:20 GMT"
---
> "Fri, 23 Feb 2024 04:41:26 GMT"
238c238
< "ABPtcPr4C4qeJPyF1Hs355ngmuBi86yohwEJAjwNpot2D32-YoWdjJw1MFzIPpH05tJd7MOZRg"
---
> "ABPtcPo4ozm6fchsDbEgNQzPavrkXLk314QaszAfZssPn9pGFsQAOM8Rrwm1Zyn39NKjIOX6xtIagqF3qg" The two key differences are in Body (before){
"kind":"storage#object",
"id":"stanhu-test/blob-for-reading/1708663160206161",
"selfLink":"https://www.googleapis.com/storage/v1/b/stanhu-test/o/blob-for-reading",
"mediaLink":"https://storage.googleapis.com/download/storage/v1/b/stanhu-test/o/blob-for-reading?generation=1708663160206161&alt=media",
"name":"blob-for-reading",
"bucket":"stanhu-test",
"generation":"1708663160206161",
"metageneration":"1",
"contentType":"text/html; charset=utf-8",
"storageClass":"STANDARD",
"size":"6354",
"md5Hash":"D2p8n/PT13C49/oZwq4Z0A==",
"crc32c":"tdwrgQ==",
"etag":"CNHm0aXSwIQDEAE=",
"timeCreated":"2024-02-23T04:39:20.256Z",
"updated":"2024-02-23T04:39:20.256Z",
"timeStorageClassUpdated":"2024-02-23T04:39:20.256Z"
} Body (after){
"kind": "storage#object",
"id": "stanhu-test/blob-for-reading/1708663285579958",
"selfLink": "https://www.googleapis.com/storage/v1/b/stanhu-test/o/blob-for-reading",
"mediaLink": "https://storage.googleapis.com/download/storage/v1/b/stanhu-test/o/blob-for-reading?generation=1708663285579958&alt=media",
"name": "blob-for-reading",
"bucket": "stanhu-test",
"generation": "1708663285579958",
"metageneration": "1",
"storageClass": "STANDARD",
"size": "6354",
"md5Hash": "D2p8n/PT13C49/oZwq4Z0A==",
"crc32c": "tdwrgQ==",
"etag": "CLaBtuHSwIQDEAE=",
"timeCreated": "2024-02-23T04:41:25.615Z",
"updated": "2024-02-23T04:41:25.615Z",
"timeStorageClassUpdated": "2024-02-23T04:41:25.615Z"
} You can see |
53a0705
to
74b5319
Compare
I also see that googleapis/google-cloud-go#9211 introduced the |
This is needed in preparation for google#3381. googleapis/google-cloud-go#9211 introduced the `includeFoldersAsPrefixes=false` query string in the URLs.
This is needed in preparation for google#3381. googleapis/google-cloud-go#9211 introduced the `includeFoldersAsPrefixes=false` query string in the URLs.
As noted on the other PR, let's wait until there is a released version with the change you need, then ping me here and I'll update the dependency version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've submitted a PR to update dependencies, so you should be able to go ahead with this now.
74b5319
to
2132176
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3381 +/- ##
=======================================
Coverage 73.15% 73.15%
=======================================
Files 113 113
Lines 14846 14848 +2
=======================================
+ Hits 10860 10862 +2
Misses 3213 3213
Partials 773 773 ☔ View full report in Codecov by Sentry. |
@vangent Thanks for your help! I think this is ready to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the PR to drop all of the go.mod and go.sum changes? IIUC those aren't necessary anymore.
@vangent |
Hmm, I thought you said that the change you needed was released, and then I updated dependencies to the latest. Did something else change, or ...? I'd rather have the dependency updates separate from code changes. |
@vangent Sorry, I should have clarified. I proposed updating to v1.39.0 was just released yesterday with the change this pull request needs with the |
Ah, OK. I will submit a separate PR to update that dependency, after which you should be able to rebase this one and have it just be the code change. Do Azure/AWS not have any way to disable any content-type detection they are doing? |
Thanks.
Azure appears to set the Content-Type to I'm going to test with AWS, but a cursory scan did not show any |
google#3371 made it possible to disable Go Cloud's Content-Type auto-detection via the `DisableContentTypeDetection` option. However, the Google Cloud Storage (GCS) driver still performed auto-detection even if this option were enabled, so it was previously not possible to keep `Content-Type` blank. This commit adds the `DisableContentTypeDetection` option to the the driver and passes along the value to make it possible to keep Content-Type blank in the GCS object metadata. This enables the use of the `Response-Content-Type` override in a signed URL. This commit needs cloud.google.com/go/storage v1.39 (googleapis/google-cloud-go#9431).
2132176
to
71bf492
Compare
I confirmed that AWS leaves the diff --git a/aws/aws.go b/aws/aws.go
index 55dc3864..478d11fc 100644
--- a/aws/aws.go
+++ b/aws/aws.go
@@ -83,6 +83,7 @@ func (co ConfigOverrider) ClientConfig(serviceName string, cfgs ...*aws.Config)
// - s3ForcePathStyle: A value of "true" forces the request to use path-style addressing; sets aws.Config.S3ForcePathStyle.
func ConfigFromURLParams(q url.Values) (*aws.Config, error) {
var cfg aws.Config
+ cfg.LogLevel = aws.LogLevel(aws.LogDebug)
for param, values := range q {
value := values[0]
switch param {
diff --git a/samples/gocdk-blob/main.go b/samples/gocdk-blob/main.go
index 2d0449e9..b92978e4 100644
--- a/samples/gocdk-blob/main.go
+++ b/samples/gocdk-blob/main.go
@@ -192,7 +192,8 @@ func (*uploadCmd) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{}
defer bucket.Close()
// Open a *blob.Writer for the blob at blobKey.
- writer, err := bucket.NewWriter(ctx, blobKey, nil)
+ opts := blob.WriterOptions{DisableContentTypeDetection: true}
+ writer, err := bucket.NewWriter(ctx, blobKey, &opts)
if err != nil {
log.Printf("Failed to write %q: %v\n", blobKey, err)
return subcommands.ExitFailure Then I used
The download confirmed a blank
|
#3371 made it possible to disable Go Cloud's Content-Type auto-detection via the
DisableContentTypeDetection
option. However, the Google Cloud Storage (GCS) driver still performed auto-detection even if this option were enabled, so it was previously not possible to keepContent-Type
blank. This commit adds theDisableContentTypeDetection
option to the the driver and passes along the value to make it possible to keep Content-Type blank in the GCS object metadata. This enables the use of theResponse-Content-Type
override in a signed URL.This commit needs cloud.google.com/go/storage v1.39 (googleapis/google-cloud-go#9431).