Skip to content

Commit

Permalink
blob/gcsblob: Ensure driver sets Content-Type auto-detection properly (
Browse files Browse the repository at this point in the history
  • Loading branch information
stanhu authored Mar 1, 2024
1 parent 6ca965e commit 7750aa6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
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,
}
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

0 comments on commit 7750aa6

Please sign in to comment.