From 3c0c7148fd53bd3ac6253b8a3997c718e007d941 Mon Sep 17 00:00:00 2001 From: Maxime VISONNEAU Date: Fri, 10 May 2024 03:13:46 +0200 Subject: [PATCH] blob: permit skipping the configuration of the Content-Disposition header (#4832) This change would allow users to disable the `Content-Disposition` header that is set for blob storage operations. The application will continue to set a default value for `Content-Disposition` of `attachment; filename={{.Filename}}` if no value was provided by the user. However, with this change, users can now specifically disable this header by setting the value to "-" in the configuration. We feel this would be a nice solution for this issue: https://github.com/Homebrew/brew/issues/15604 --- internal/pipe/blob/blob.go | 4 ++++ internal/pipe/blob/blob_test.go | 7 ++++--- www/docs/customization/blob.md | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/pipe/blob/blob.go b/internal/pipe/blob/blob.go index 6c4f1d5b19b..e5dd74a97c9 100644 --- a/internal/pipe/blob/blob.go +++ b/internal/pipe/blob/blob.go @@ -33,9 +33,13 @@ func (Pipe) Default(ctx *context.Context) error { if blob.Directory == "" { blob.Directory = "{{ .ProjectName }}/{{ .Tag }}" } + if blob.ContentDisposition == "" { blob.ContentDisposition = "attachment;filename={{.Filename}}" + } else if blob.ContentDisposition == "-" { + blob.ContentDisposition = "" } + if blob.OldDisableSSL { deprecate.Notice(ctx, "blobs.disableSSL") blob.DisableSSL = true diff --git a/internal/pipe/blob/blob_test.go b/internal/pipe/blob/blob_test.go index d63070d7ddb..bbdf25c71ca 100644 --- a/internal/pipe/blob/blob_test.go +++ b/internal/pipe/blob/blob_test.go @@ -75,8 +75,9 @@ func TestDefaults(t *testing.T) { ContentDisposition: "inline", }, { - Bucket: "foobar", - Provider: "gcs", + Bucket: "foobar", + Provider: "gcs", + ContentDisposition: "-", }, { Bucket: "deprecated", @@ -100,7 +101,7 @@ func TestDefaults(t *testing.T) { Bucket: "foobar", Provider: "gcs", Directory: "{{ .ProjectName }}/{{ .Tag }}", - ContentDisposition: "attachment;filename={{.Filename}}", + ContentDisposition: "", }, { Bucket: "deprecated", diff --git a/www/docs/customization/blob.md b/www/docs/customization/blob.md index 0a95856cb74..f5d97ac8ed6 100644 --- a/www/docs/customization/blob.md +++ b/www/docs/customization/blob.md @@ -116,6 +116,7 @@ blobs: # Since: v1.24 # Default: attachment;filename={{.Filename}} # Templates: allowed + # Disable by setting the value to '-' content_disposition: "inline" - provider: gs