mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: add support for s3 path (#1233)
* add support for path * fix typo and switch positions with Path and Bucket * using path method instead of string concatenation
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"path"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
s3config "github.com/aws/aws-sdk-go-v2/config"
|
||||
@ -18,6 +19,7 @@ type Config struct {
|
||||
SecretKey string
|
||||
Bucket string
|
||||
EndPoint string
|
||||
Path string
|
||||
Region string
|
||||
URLPrefix string
|
||||
}
|
||||
@ -55,7 +57,7 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileType
|
||||
uploader := manager.NewUploader(client.Client)
|
||||
uploadOutput, err := uploader.Upload(ctx, &awss3.PutObjectInput{
|
||||
Bucket: aws.String(client.Config.Bucket),
|
||||
Key: aws.String(filename),
|
||||
Key: aws.String(path.Join(client.Config.Path, filename)),
|
||||
Body: src,
|
||||
ContentType: aws.String(fileType),
|
||||
ACL: types.ObjectCannedACL(*aws.String("public-read")),
|
||||
|
Reference in New Issue
Block a user