From e24913484920dea292c8e06d5aa1158858417e95 Mon Sep 17 00:00:00 2001 From: phbnf Date: Mon, 19 Aug 2024 18:19:24 +0100 Subject: [PATCH] Fix contenttype (#151) Need to initialize the writer before setting the content type --- storage/gcp/gcp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/gcp/gcp.go b/storage/gcp/gcp.go index 47797379..46b95dbd 100644 --- a/storage/gcp/gcp.go +++ b/storage/gcp/gcp.go @@ -669,13 +669,13 @@ func (s *gcsStorage) setObject(ctx context.Context, objName string, data []byte, obj := bkt.Object(objName) var w *gcs.Writer - w.ObjectAttrs.ContentType = contType if cond == nil { w = obj.NewWriter(ctx) } else { w = obj.If(*cond).NewWriter(ctx) } + w.ObjectAttrs.ContentType = contType if _, err := w.Write(data); err != nil { return fmt.Errorf("failed to write object %q to bucket %q: %w", objName, s.bucket, err) }