From 6eebdd6d5eba2d0c9bda10da035ac9099cb775f3 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Sat, 18 Nov 2023 17:26:10 -0800 Subject: [PATCH] Add Expires to PutObject opts (#1900) --- .github/workflows/vulncheck.yml | 2 +- api-put-object.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/vulncheck.yml b/.github/workflows/vulncheck.yml index 2d3beaa9b..3ae0b8538 100644 --- a/.github/workflows/vulncheck.yml +++ b/.github/workflows/vulncheck.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [ 1.21.0 ] + go-version: [ 1.21.4 ] steps: - name: Check out code into the Go module directory uses: actions/checkout@v3 diff --git a/api-put-object.go b/api-put-object.go index 2c4de4f96..bbd8924e2 100644 --- a/api-put-object.go +++ b/api-put-object.go @@ -77,6 +77,7 @@ type PutObjectOptions struct { ContentDisposition string ContentLanguage string CacheControl string + Expires time.Time Mode RetentionMode RetainUntilDate time.Time ServerSideEncryption encrypt.ServerSide @@ -153,6 +154,10 @@ func (opts PutObjectOptions) Header() (header http.Header) { header.Set("Cache-Control", opts.CacheControl) } + if !opts.Expires.IsZero() { + header.Set("Expires", opts.Expires.UTC().Format(http.TimeFormat)) + } + if opts.Mode != "" { header.Set(amzLockMode, opts.Mode.String()) }