π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Fix avatar uploads
Smaug6739eeafd427a59f
diff --git a/backend/config.toml b/backend/config.tomlindex 0f53e426..55c9d064 100644--- a/backend/config.toml+++ b/backend/config.toml@@ -25,6 +25,7 @@ SupportedTypes = ["image/gif","image/bmp","image/webp",+ "image/avif", # .avif"image/svg+xml","image/vnd.microsoft.icon",# video formatsdiff --git a/backend/controllers/ressources.controller.go b/backend/controllers/ressources.controller.goindex 45488bcb..814cd011 100644--- a/backend/controllers/ressources.controller.go+++ b/backend/controllers/ressources.controller.go@@ -94,11 +94,11 @@ func (ctr *Controller) UploadFile(c *gin.Context) (int, any) {Filesize: header.Size,Filetype: mimeType,OriginalPath: header.Filename,- TransformedPath: "uploads/" + header.Filename,+ TransformedPath: header.Filename,AuthorId: userId,CreatedTimestamp: time.Now().UnixMilli(),}- objectName := fmt.Sprintf("uploads/%d/%d%s", ressource.AuthorId, ressource.Id, ext)+ objectName := fmt.Sprintf("%d/%d%s", ressource.AuthorId, ressource.Id, ext)_, err = ctr.app.Services.Ressource.CreateRessource(ressource)if err != nil {@@ -147,7 +147,7 @@ func (ctr *Controller) UploadAvatar(c *gin.Context) (int, any) {return http.StatusBadRequest, err}- objectName := fmt.Sprintf("uploads/%d/%s", userId, "avatar")+ objectName := fmt.Sprintf("%d/%s", userId, "avatar")_, err = ctr.app.MinioClient.PutObject(c, os.Getenv("MINIO_BUCKET"), objectName, file, header.Size, minio.PutObjectOptions{ContentType: header.Header.Get("Content-Type")})if err != nil {@@ -186,7 +186,7 @@ func (ctr *Controller) DeleteUpload(c *gin.Context) (int, any) {return http.StatusUnauthorized, errors.New("you are not authorized to delete this ressource")}- prefix := fmt.Sprintf("uploads/%d/%d", ressource.AuthorId, ressource.Id)+ prefix := fmt.Sprintf("%d/%d", ressource.AuthorId, ressource.Id)// List all objects in the bucket with the given prefixctx := context.Background()objectCh := ctr.app.MinioClient.ListObjects(ctx, os.Getenv("MINIO_BUCKET"), minio.ListObjectsOptions{diff --git a/backend/router/routes/ressources.go b/backend/router/routes/ressources.goindex 312a8731..1ddf7ab7 100644--- a/backend/router/routes/ressources.go+++ b/backend/router/routes/ressources.go@@ -14,9 +14,8 @@ func Uploads(app *app.App, router *gin.RouterGroup) {ressourcesCtrl := controllers.NewRessourceController(app)ressources.Use(middlewares.Auth())-ressources.GET(("/:userId"), utils.WP(ressourcesCtrl.GetAllUploads))ressources.POST("", utils.WP(ressourcesCtrl.UploadFile))- ressources.GET("/avatar", utils.WP(ressourcesCtrl.UploadAvatar))+ ressources.POST("/avatar", utils.WP(ressourcesCtrl.UploadAvatar))ressources.DELETE("/:id", utils.WP(ressourcesCtrl.DeleteUpload))}