diff --git a/api/storage.go b/api/storage.go index 1acedc86..b538c956 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.go index 87801224..6ecbab68 100644 --- a/plugin/storage/s3/s3.go +++ b/plugin/storage/s3/s3.go @@ -20,6 +20,7 @@ type Config struct { EndPoint string Region string URLPrefix string + URLSuffix string } type Client struct { @@ -67,7 +68,7 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileType link := 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.go index c49e51f8..ec4022bb 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.tsx index 72f99828..db8e29da 100644 --- a/web/src/components/CreateStorageServiceDialog.tsx +++ b/web/src/components/CreateStorageServiceDialog.tsx @@ -25,6 +25,7 @@ const CreateStorageServiceDialog: React.FC = (props: Props) => { path: "", bucket: "", urlPrefix: "", + urlSuffix: "", }); const isCreating = storage === undefined; @@ -221,6 +222,17 @@ const CreateStorageServiceDialog: React.FC = (props: Props) => { onChange={(e) => setPartialS3Config({ urlPrefix: e.target.value })} fullWidth /> + + URLSuffix + (Custom URL suffix; Optional) + + setPartialS3Config({ urlSuffix: e.target.value })} + fullWidth + />