auth-uploads #5

Merged
grng merged 9 commits from auth-uploads into dev 2025-06-08 18:02:57 +00:00
Showing only changes of commit 8942778377 - Show all commits

View file

@ -4,6 +4,7 @@ import (
"encoding/base64" "encoding/base64"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -63,7 +64,17 @@ func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
api.GET("/:name", func(c *gin.Context) { api.GET("/:name", func(c *gin.Context) {
name := c.Param("name") name := c.Param("name")
path := filepath.Join(cfg.ImagePath, name) parts := strings.SplitN(name, "_", 2)
if len(parts) != 2 {
c.JSON(400, gin.H{"error": "invalid file name"})
return
}
uid, filename := parts[0], parts[1]
path := filepath.Join(cfg.ImagePath, uid, filename)
if _, err := os.Stat(path); err != nil {
c.JSON(404, gin.H{"error": "file not found"})
return
}
c.File(path) c.File(path)
}) })