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 URLSuffix resource option with S3 (#1428)
Xudong Caid21abfc60c3d
diff --git a/api/storage.go b/api/storage.goindex 1acedc86c..b538c9563 100644--- a/api/storage.go+++ b/api/storage.go@@ -18,6 +18,7 @@ type StorageS3Config struct {SecretKey string `json:"secretKey"`Bucket string `json:"bucket"`URLPrefix string `json:"urlPrefix"`+ URLSuffix string `json:"urlSuffix"`}type Storage struct {diff --git a/plugin/storage/s3/s3.go b/plugin/storage/s3/s3.goindex 878012248..6ecbab685 100644--- a/plugin/storage/s3/s3.go+++ b/plugin/storage/s3/s3.go@@ -20,6 +20,7 @@ type Config struct {EndPoint stringRegion stringURLPrefix string+ URLSuffix string}type Client struct {@@ -67,7 +68,7 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileTypelink := uploadOutput.Location// If url prefix is set, use it as the file link.if client.Config.URLPrefix != "" {- link = fmt.Sprintf("%s/%s", client.Config.URLPrefix, filename)+ link = fmt.Sprintf("%s/%s%s", client.Config.URLPrefix, filename, client.Config.URLSuffix)}if link == "" {return "", fmt.Errorf("failed to get file link")diff --git a/server/resource.go b/server/resource.goindex c49e51f86..ec4022bb5 100644--- a/server/resource.go+++ b/server/resource.go@@ -194,6 +194,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {Region: s3Config.Region,Bucket: s3Config.Bucket,URLPrefix: s3Config.URLPrefix,+ URLSuffix: s3Config.URLSuffix,})if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to new s3 client").SetInternal(err)diff --git a/web/src/components/CreateStorageServiceDialog.tsx b/web/src/components/CreateStorageServiceDialog.tsxindex 72f99828b..db8e29da5 100644--- a/web/src/components/CreateStorageServiceDialog.tsx+++ b/web/src/components/CreateStorageServiceDialog.tsx@@ -25,6 +25,7 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {path: "",bucket: "",urlPrefix: "",+ urlSuffix: "",});const isCreating = storage === undefined;@@ -221,6 +222,17 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {onChange={(e) => setPartialS3Config({ urlPrefix: e.target.value })}fullWidth/>+ <Typography className="!mb-1" level="body2">+ URLSuffix+ <span className="text-sm text-gray-400 ml-1">(Custom URL suffix; Optional)</span>+ </Typography>+ <Input+ className="mb-2"+ placeholder="URLSuffix"+ value={s3Config.urlSuffix}+ onChange={(e) => setPartialS3Config({ urlSuffix: e.target.value })}+ fullWidth+ /><div className="mt-2 w-full flex flex-row justify-end items-center space-x-1"><Button variant="plain" color="neutral" onClick={handleCloseBtnClick}>Canceldiff --git a/web/src/types/modules/storage.d.ts b/web/src/types/modules/storage.d.tsindex 22e0d447a..fe0f8e9a4 100644--- a/web/src/types/modules/storage.d.ts+++ b/web/src/types/modules/storage.d.ts@@ -10,6 +10,7 @@ interface StorageS3Config {path: string;bucket: string;urlPrefix: string;+ urlSuffix: string;}interface StorageConfig {