From d0a5767d30272c065a075a283fd2ba563834baca Mon Sep 17 00:00:00 2001 From: Haytham Abuelfutuh Date: Thu, 7 Apr 2022 17:10:37 -0700 Subject: [PATCH] Support Content MD5 hash (#126) * Support Content MD5 hash Signed-off-by: Haytham Abuelfutuh * Update to released stow version Signed-off-by: Haytham Abuelfutuh * Update to released stow version Signed-off-by: Haytham Abuelfutuh --- go.mod | 2 +- go.sum | 4 ++-- storage/storage.go | 7 ++++++- storage/stow_store.go | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 828f3b5..bedadd0 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/ernesto-jimenez/gogen v0.0.0-20180125220232-d7d4131e6607 github.com/fatih/color v1.10.0 github.com/fatih/structtag v1.2.0 - github.com/flyteorg/stow v0.3.1 + github.com/flyteorg/stow v0.3.3 github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 github.com/go-test/deep v1.0.7 diff --git a/go.sum b/go.sum index 6e2d197..c160604 100644 --- a/go.sum +++ b/go.sum @@ -174,8 +174,8 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= -github.com/flyteorg/stow v0.3.1 h1:cBMbWl03Gsy5KoA5mutUYTuYpqtT7Pb8+ANGCLnmFEs= -github.com/flyteorg/stow v0.3.1/go.mod h1:HBld7ud0i4khMHwJjkO8v+NSP7ddKa/ruhf4I8fliaA= +github.com/flyteorg/stow v0.3.3 h1:tzeNl8mSZFL3oJDi0ACZj6FAineQAF4qyEp6bXtIdQY= +github.com/flyteorg/stow v0.3.3/go.mod h1:HBld7ud0i4khMHwJjkO8v+NSP7ddKa/ruhf4I8fliaA= github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= diff --git a/storage/storage.go b/storage/storage.go index 474e38d..86c4427 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -43,9 +43,14 @@ type DataStore struct { ReferenceConstructor } +// SignedURLProperties encapsulates properties about the signedURL operation. type SignedURLProperties struct { - Scope stow.ClientMethod + // Scope defines the permission level allowed for the generated URL. + Scope stow.ClientMethod + // ExpiresIn defines the expiration duration for the URL. It's strongly recommended setting it. ExpiresIn time.Duration + // ContentMD5 defines the expected hash of the generated file. It's strongly recommended setting it. + ContentMD5 string } type SignedURLResponse struct { diff --git a/storage/stow_store.go b/storage/stow_store.go index 175389f..6793390 100644 --- a/storage/stow_store.go +++ b/storage/stow_store.go @@ -303,7 +303,8 @@ func (s *StowStore) CreateSignedURL(ctx context.Context, reference DataReference } urlStr, err := c.PreSignRequest(ctx, properties.Scope, key, stow.PresignRequestParams{ - ExpiresIn: properties.ExpiresIn, + ExpiresIn: properties.ExpiresIn, + ContentMD5: properties.ContentMD5, }) if err != nil {