-
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: Allow blank Content-Type to be set #3298
Comments
@vangent What do you think about introducing a |
Yea, the driver interface says
so I'm a bit leery of breaking that promise.
Sorry, I don't quite follow this, can you explain? What are you trying to do? The documentation for this header says
Based on that, it sounds to me like GCS's behavior is correct, no? I think you're implying that you're passing a |
@vagent Sorry I took so long to respond. We have a system where users upload files via Git LFS (Large File System), and they can browse their project. If they click on a LFS file, we want to be careful we set both When a LFS file is uploaded, we originally stored them as However, if the file is an image such as JPEG or PNG, we want to display the file to the user with the right With GCS, if the object has been stored with With AWS, even if the object has been stored as It's easier to tag the
That's an acceptable use case in AWS, though. Most of the time we don't want to inspect the blob to determine |
Where does Go CDK fit into the above? You suggested updating |
We use We want to leave this |
See #3371. Note that I can't really test this very well, because even though we write the blobs to the backend with an empty ContentType, when we read it back it's not blank. DIfferent backends return different things (e.g., s3 returns "application/octet-stream", while GCS seems to do its own content sniffing). |
Many thanks for the work @vangent! I was testing the changes and disabled the content type detection, but anyhow it was still set. The type that appeared in GCS seems to be auto detected since it's not the real one: |
It looks like the Google Storage SDK also does Content-Type sniffing: googleapis/google-cloud-go#9430 |
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value.
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
As described in google/go-cloud#3298 (comment), we want to disable automatic `Content-Type` detection when inserting an object to Google Cloud Storage (GCS). Previously it wasn't possible to disable this auto-detection, even though `googleapi.MediaOptions` provides a `ForceEmptyContentType` option (https://github.com/googleapis/google-api-go-client/blob/v0.165.0/googleapi/googleapi.go#L283). We enable this by adding a `Writer` option to set this value. Closes googleapis#9430
Describe the bug
Google Cloud Storage allows a client to request a blob with a different
Content-Type
via theresponse-content-type
query parameter only if the blob'sContent-Type
metadata has NOT already been set.This differs from Amazon S3, which allows
response-content-type
to be requested regardless of the blob metadata.With Go Cloud, It's currently not possible to keep the
Content-Type
value blank for GCS. https://github.com/google/go-cloud/blob/v0.30.0/internal/docs/design.md#portable-types-and-drivers says:That seems to be happening here:
go-cloud/blob/blob.go
Lines 1109 to 1121 in d2d5bed
To Reproduce
Bucket.NewWriter
withContent-Type
blank inWriterOptions
(https://pkg.go.dev/github.com/google/go-cloud/blob#WriterOptions).Content-Type
already set.Expected behavior
The metadata should remain blank so that clients can override the type on request.
Version
v0.30.0, but this has been true for a while.
The text was updated successfully, but these errors were encountered: