From 1e93568f9b73f585f47dde4d4d45b09da95df326 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Thu, 4 May 2023 22:49:59 +0300 Subject: [PATCH] Move upload func to fs pacakge --- main.go | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/main.go b/main.go index 768e698..f93bf6f 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "context" "errors" - "fmt" "log" "net/http" "os" @@ -82,37 +81,6 @@ func main() { appsStorage.Apps["img-viewer"] = &imgViewerApp appsStorage.Apps["blog-viewer"] = blogViewerApp - router.POST("/upload", func(ctx *gin.Context) { - path := ctx.Query("path") - if path == "" { - ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct - return - } - // single file - file, _ := ctx.FormFile("file") - if file == nil { - ctx.String(http.StatusBadRequest, "file is nil") - } - // generateMins := c.Param("generateMins") - // log.Println(file.Filename) - - // Upload the file to specific dst. - dst := "./test-img/" + file.Filename - ctx.SaveUploadedFile(file, dst) - - err := webfs.UploadFile(dst, path) - if err != nil { - ctx.String(http.StatusInternalServerError, "TODO") //TODO - return - } - - // webFsCollection.CreateMiniatures("./test-img/", file.Filename) - - // webfs.CreateFile(&img, "/home/user/") - - ctx.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename)) - }) - system := router.Group("system") { libsGroup := system.Group("libs")