Skip to content

Commit

Permalink
blob: permit skipping the configuration of the Content-Disposition he…
Browse files Browse the repository at this point in the history
…ader (#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:
Homebrew/brew#15604
  • Loading branch information
mvisonneau committed May 10, 2024
1 parent 5d98c69 commit 3c0c714
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions internal/pipe/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions internal/pipe/blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ func TestDefaults(t *testing.T) {
ContentDisposition: "inline",
},
{
Bucket: "foobar",
Provider: "gcs",
Bucket: "foobar",
Provider: "gcs",
ContentDisposition: "-",
},
{
Bucket: "deprecated",
Expand All @@ -100,7 +101,7 @@ func TestDefaults(t *testing.T) {
Bucket: "foobar",
Provider: "gcs",
Directory: "{{ .ProjectName }}/{{ .Tag }}",
ContentDisposition: "attachment;filename={{.Filename}}",
ContentDisposition: "",
},
{
Bucket: "deprecated",
Expand Down
1 change: 1 addition & 0 deletions www/docs/customization/blob.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c0c714

Please sign in to comment.