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

blob/gcsblob: Ensure driver sets Content-Type auto-detection properly #3381

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,14 +1083,15 @@ func (b *Bucket) NewWriter(ctx context.Context, key string, opts *WriterOptions)
opts = &WriterOptions{}
}
dopts := &driver.WriterOptions{
CacheControl: opts.CacheControl,
ContentDisposition: opts.ContentDisposition,
ContentEncoding: opts.ContentEncoding,
ContentLanguage: opts.ContentLanguage,
ContentMD5: opts.ContentMD5,
BufferSize: opts.BufferSize,
MaxConcurrency: opts.MaxConcurrency,
BeforeWrite: opts.BeforeWrite,
CacheControl: opts.CacheControl,
ContentDisposition: opts.ContentDisposition,
ContentEncoding: opts.ContentEncoding,
ContentLanguage: opts.ContentLanguage,
ContentMD5: opts.ContentMD5,
BufferSize: opts.BufferSize,
MaxConcurrency: opts.MaxConcurrency,
BeforeWrite: opts.BeforeWrite,
DisableContentTypeDetection: opts.DisableContentTypeDetection,
stanhu marked this conversation as resolved.
Show resolved Hide resolved
}
if len(opts.Metadata) > 0 {
// Services are inconsistent, but at least some treat keys
Expand Down
4 changes: 4 additions & 0 deletions blob/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ type WriterOptions struct {
// Metadata holds key/value strings to be associated with the blob.
// Keys are guaranteed to be non-empty and lowercased.
Metadata map[string]string
// When true, the driver should attempt to disable any automatic
// content-type detection that the provider applies on writes with an
// empty ContentType.
DisableContentTypeDetection bool
// BeforeWrite is a callback that must be called exactly once before
// any data is written, unless NewTypedWriter returns an error, in
// which case it should not be called.
Expand Down
1 change: 1 addition & 0 deletions blob/gcsblob/gcsblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ func (b *bucket) NewTypedWriter(ctx context.Context, key string, contentType str
w.ChunkSize = bufferSize(opts.BufferSize)
w.Metadata = opts.Metadata
w.MD5 = opts.ContentMD5
w.ForceEmptyContentType = opts.DisableContentTypeDetection
return w
}

Expand Down
Loading