实现文件上传

This commit is contained in:
2026-06-06 17:22:01 +08:00
parent 1b39b2d411
commit b00782b3f6
10 changed files with 398 additions and 7 deletions

View File

@@ -1,11 +1,14 @@
package web
import (
"net/http"
"platform/pkg/env"
"platform/web/auth"
"github.com/gofiber/contrib/otelfiber/v2"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/gofiber/fiber/v2/middleware/requestid"
@@ -66,6 +69,11 @@ func ApplyMiddlewares(app *fiber.App) {
},
}))
// static uploads
app.Use("/uploads", filesystem.New(filesystem.Config{
Root: http.Dir(env.UploadDir),
}))
// authenticate
app.Use(auth.Authenticate())
}