fix(remote_storage/gcs): forward entry mime as ContentType (#9711)

fix(remote_storage/gcs): forward entry.Attributes.Mime as ContentType

Same gap as the S3 client: filer.remote.sync to GCS never populated
the object's ContentType, so HTML/CSS/etc. ended up stored as the GCS
default and didn't render correctly in browsers.

Mirrors the existing Azure client behavior
(weed/remote_storage/azure/azure_storage_client.go).
This commit is contained in:
Chris Lu
2026-05-27 12:21:27 -07:00
committed by GitHub
parent 9cb9699e9d
commit 396e3c326b
@@ -227,6 +227,9 @@ func (gcs *gcsRemoteStorageClient) WriteFile(loc *remote_pb.RemoteStorageLocatio
metadata := toMetadata(entry.Extended)
wc := gcs.client.Bucket(loc.Bucket).Object(key).NewWriter(context.Background())
wc.Metadata = metadata
if entry.Attributes != nil && entry.Attributes.Mime != "" {
wc.ContentType = entry.Attributes.Mime
}
if _, err = io.Copy(wc, reader); err != nil {
return nil, fmt.Errorf("upload to gcs %s/%s%s: %v", loc.Name, loc.Bucket, loc.Path, err)
}