feat(s3): customize filenames via placeholders (#1285)

* feat(s3): customize filenames via placeholders

* fix go-static-checks

* add tips on the frontend

* fix eslint check

* remove yarn.lock

* remove Config.Path

* update tips

* fix

* update
This commit is contained in:
Zeng1998
2023-03-06 20:04:19 +08:00
committed by GitHub
parent 37366dc2e1
commit fd99c5461c
3 changed files with 25 additions and 5 deletions

View File

@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"path"
"github.com/aws/aws-sdk-go-v2/aws"
s3config "github.com/aws/aws-sdk-go-v2/config"
@@ -19,7 +18,6 @@ type Config struct {
SecretKey string
Bucket string
EndPoint string
Path string
Region string
URLPrefix string
}
@@ -57,7 +55,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(path.Join(client.Config.Path, filename)),
Key: aws.String(filename),
Body: src,
ContentType: aws.String(fileType),
ACL: types.ObjectCannedACL(*aws.String("public-read")),