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.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
feat: add support for s3 path (#1233)
Alex Zhao9d4bb5b3af0d
diff --git a/api/storage.go b/api/storage.goindex d45183545..1acedc86c 100644--- a/api/storage.go+++ b/api/storage.go@@ -12,6 +12,7 @@ type StorageConfig struct {type StorageS3Config struct {EndPoint string `json:"endPoint"`+ Path string `json:"path"`Region string `json:"region"`AccessKey string `json:"accessKey"`SecretKey string `json:"secretKey"`diff --git a/plugin/storage/s3/s3.go b/plugin/storage/s3/s3.goindex d7b936974..e00e96052 100644--- a/plugin/storage/s3/s3.go+++ b/plugin/storage/s3/s3.go@@ -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 stringBucket stringEndPoint string+ Path stringRegion stringURLPrefix string}@@ -55,7 +57,7 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileTypeuploader := 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")),diff --git a/server/resource.go b/server/resource.goindex 2e16def3b..831579284 100644--- a/server/resource.go+++ b/server/resource.go@@ -139,6 +139,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {AccessKey: s3Config.AccessKey,SecretKey: s3Config.SecretKey,EndPoint: s3Config.EndPoint,+ Path: s3Config.Path,Region: s3Config.Region,Bucket: s3Config.Bucket,URLPrefix: s3Config.URLPrefix,diff --git a/web/src/components/CreateStorageServiceDialog.tsx b/web/src/components/CreateStorageServiceDialog.tsxindex 92cd2b960..196293fa8 100644--- a/web/src/components/CreateStorageServiceDialog.tsx+++ b/web/src/components/CreateStorageServiceDialog.tsx@@ -21,6 +21,7 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {region: "",accessKey: "",secretKey: "",+ path: "",bucket: "",urlPrefix: "",});@@ -181,6 +182,17 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {onChange={(e) => setPartialS3Config({ bucket: e.target.value })}fullWidth/>+ <Typography className="!mb-1" level="body2">+ Path+ <span className="text-sm text-gray-400 ml-1">(Storage Path)</span>+ </Typography>+ <Input+ className="mb-2"+ placeholder="Path"+ value={s3Config.path}+ onChange={(e) => setPartialS3Config({ path: e.target.value })}+ fullWidth+ /><Typography className="!mb-1" level="body2">URLPrefix<span className="text-sm text-gray-400 ml-1">(Custom URL prefix; Optional)</span>diff --git a/web/src/types/modules/storage.d.ts b/web/src/types/modules/storage.d.tsindex 2221678fe..22e0d447a 100644--- a/web/src/types/modules/storage.d.ts+++ b/web/src/types/modules/storage.d.ts@@ -7,6 +7,7 @@ interface StorageS3Config {region: string;accessKey: string;secretKey: string;+ path: string;bucket: string;urlPrefix: string;}