diff --git a/providers/s3/s3.go b/providers/s3/s3.go index dad89e66..2ca0cfd4 100644 --- a/providers/s3/s3.go +++ b/providers/s3/s3.go @@ -14,6 +14,7 @@ import ( "strconv" "strings" "testing" + "time" "github.com/efficientgo/core/logerrcapture" "github.com/go-kit/log" @@ -651,3 +652,16 @@ func NewTestBucketFromConfig(t testing.TB, location string, c Config, reuseBucke func ContextWithSSEConfig(ctx context.Context, value encrypt.ServerSide) context.Context { return context.WithValue(ctx, sseConfigKey, value) } + +// SignedPUT Returns a presigned URL to upload an object without credentials. URL can have a maximum expiry of upto 7days or a minimum of 1sec. +func (b *Bucket) SignedPUT( + ctx context.Context, + objectKey string, + expiry time.Time, +) (string, error) { + u, err := b.client.PresignedPutObject(ctx, b.name, objectKey, expiry.Sub(time.Now())) + if err != nil { + return "", err + } + return u.String(), nil +}