Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/s3: SignedPUT. #127

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"strconv"
"strings"
"testing"
"time"

"github.com/efficientgo/core/logerrcapture"
"github.com/go-kit/log"
Expand Down Expand Up @@ -651,3 +652,16 @@
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()))

Check failure on line 662 in providers/s3/s3.go

View workflow job for this annotation

GitHub Actions / Linters (Static Analysis) for Go

S1024: should use time.Until instead of t.Sub(time.Now()) (gosimple)
if err != nil {
return "", err
}
return u.String(), nil
}
Loading