Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: remove ACL when set URLPrefix (#2532)

Hou Xiaoxuane016244abac1
diff --git a/plugin/storage/s3/s3.go b/plugin/storage/s3/s3.go
index 10b05392a..d7c2a9d35 100644
--- a/plugin/storage/s3/s3.go
+++ b/plugin/storage/s3/s3.go
@@ -64,13 +64,17 @@ func NewClient(ctx context.Context, config *Config) (*Client, error) {
func (client *Client) UploadFile(ctx context.Context, filename string, fileType string, src io.Reader) (string, error) {
uploader := manager.NewUploader(client.Client)
- uploadOutput, err := uploader.Upload(ctx, &awss3.PutObjectInput{
+ // set ACL according to if user set prefix
+ obj := awss3.PutObjectInput{
Bucket: aws.String(client.Config.Bucket),
Key: aws.String(filename),
Body: src,
ContentType: aws.String(fileType),
- ACL: types.ObjectCannedACL(*aws.String("public-read")),
- })
+ }
+ if client.Config.URLPrefix == "" {
+ obj.ACL = types.ObjectCannedACL(*aws.String("public-read"))
+ }
+ uploadOutput, err := uploader.Upload(ctx, &obj)
if err != nil {
return "", err
}