Skip to content

Commit

Permalink
Merge pull request #2 from flyteorg/content-md5
Browse files Browse the repository at this point in the history
Support ContentMD5 as an optional param
  • Loading branch information
EngHabu authored Apr 7, 2022
2 parents 8ee1921 + b9d38a1 commit 31630d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions google/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (c *Container) PreSignRequest(_ context.Context, clientMethod stow.ClientMe
return storage.SignedURL(c.name, id, &storage.SignedURLOptions{
Method: params.HttpMethod,
Expires: time.Now().Add(params.ExpiresIn),
MD5: params.ContentMD5,
})
}

Expand Down
10 changes: 8 additions & 2 deletions s3/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ func (c *container) PreSignRequest(ctx context.Context, clientMethod stow.Client
Key: aws.String(id),
})
case stow.ClientMethodPut:
var contentMD5 *string
if len(params.ContentMD5) > 0 {
contentMD5 = aws.String(params.ContentMD5)
}

req, _ = c.client.PutObjectRequest(&s3.PutObjectInput{
Bucket: aws.String(c.name),
Key: aws.String(id),
Bucket: aws.String(c.name),
Key: aws.String(id),
ContentMD5: contentMD5,
})
default:
return "", fmt.Errorf("unsupported client method [%v]", clientMethod.String())
Expand Down
2 changes: 1 addition & 1 deletion stow.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type Location interface {

type PresignRequestParams struct {
ExpiresIn time.Duration
ContentMD5 string
ExtraParams map[string]interface{}
HttpMethod HttpMethod
}
Expand Down Expand Up @@ -120,7 +121,6 @@ type Container interface {
// Put creates a new Item with the specified name, and contents
// read from the reader.
Put(name string, r io.Reader, size int64, metadata map[string]interface{}) (Item, error)

// PreSignRequest generates a pre-signed url for the given id (key after bucket/container) and a given clientMethod.
PreSignRequest(ctx context.Context, clientMethod ClientMethod, id string, params PresignRequestParams) (url string, err error)
}
Expand Down

0 comments on commit 31630d5

Please sign in to comment.