|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"path"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go-v2/aws"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/aws"
|
|
|
|
s3config "github.com/aws/aws-sdk-go-v2/config"
|
|
|
|
s3config "github.com/aws/aws-sdk-go-v2/config"
|
|
|
@ -18,6 +19,7 @@ type Config struct {
|
|
|
|
SecretKey string
|
|
|
|
SecretKey string
|
|
|
|
Bucket string
|
|
|
|
Bucket string
|
|
|
|
EndPoint string
|
|
|
|
EndPoint string
|
|
|
|
|
|
|
|
Path string
|
|
|
|
Region string
|
|
|
|
Region string
|
|
|
|
URLPrefix string
|
|
|
|
URLPrefix string
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -55,7 +57,7 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileType
|
|
|
|
uploader := manager.NewUploader(client.Client)
|
|
|
|
uploader := manager.NewUploader(client.Client)
|
|
|
|
uploadOutput, err := uploader.Upload(ctx, &awss3.PutObjectInput{
|
|
|
|
uploadOutput, err := uploader.Upload(ctx, &awss3.PutObjectInput{
|
|
|
|
Bucket: aws.String(client.Config.Bucket),
|
|
|
|
Bucket: aws.String(client.Config.Bucket),
|
|
|
|
Key: aws.String(filename),
|
|
|
|
Key: aws.String(path.Join(client.Config.Path, filename)),
|
|
|
|
Body: src,
|
|
|
|
Body: src,
|
|
|
|
ContentType: aws.String(fileType),
|
|
|
|
ContentType: aws.String(fileType),
|
|
|
|
ACL: types.ObjectCannedACL(*aws.String("public-read")),
|
|
|
|
ACL: types.ObjectCannedACL(*aws.String("public-read")),
|
|
|
|