diff --git a/blob/blob.go b/blob/blob.go index a1a14d85d..d64ed22fc 100644 --- a/blob/blob.go +++ b/blob/blob.go @@ -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 diff --git a/blob/driver/driver.go b/blob/driver/driver.go index 1fbae1a2d..0fa885f17 100644 --- a/blob/driver/driver.go +++ b/blob/driver/driver.go @@ -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. diff --git a/blob/gcsblob/gcsblob.go b/blob/gcsblob/gcsblob.go index 737b2c12d..8ff289083 100644 --- a/blob/gcsblob/gcsblob.go +++ b/blob/gcsblob/gcsblob.go @@ -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 }