Skip to content

Commit ac076fd

Browse files
committed
feat: #135 Generate presigned URL
Signed-off-by: Suraj Patil <[email protected]>
1 parent 7adf08b commit ac076fd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

providers/s3/s3.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"strconv"
1515
"strings"
1616
"testing"
17+
"time"
1718

1819
"github.com/efficientgo/core/logerrcapture"
1920
"github.com/go-kit/log"
@@ -546,6 +547,15 @@ func (b *Bucket) Delete(ctx context.Context, name string) error {
546547
return b.client.RemoveObject(ctx, b.name, name, minio.RemoveObjectOptions{})
547548
}
548549

550+
// Get Presigned URL for uploading tsdb blocks.
551+
func (b *Bucket) GetPresignedUploadURL(ctx context.Context, name string, expiry time.Duration) (string, error) {
552+
presignedUrl, err := b.client.PresignedPutObject(ctx, b.name, name, expiry)
553+
if err != nil {
554+
return "", err
555+
}
556+
return presignedUrl.String(), nil
557+
}
558+
549559
// IsObjNotFoundErr returns true if error means that object is not found. Relevant to Get operations.
550560
func (b *Bucket) IsObjNotFoundErr(err error) bool {
551561
return minio.ToErrorResponse(errors.Cause(err)).Code == "NoSuchKey"

0 commit comments

Comments
 (0)