Move upload func to fs pacakge
This commit is contained in:
parent
ccc24b93ad
commit
1e93568f9b
32
main.go
32
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")
|
||||
|
Loading…
Reference in New Issue
Block a user