diff --git a/internal/api/routes/files.go b/internal/api/routes/files.go index 3a3f48e..e827e17 100644 --- a/internal/api/routes/files.go +++ b/internal/api/routes/files.go @@ -20,7 +20,6 @@ func intoReader(buf []byte) io.Reader { return io.NopCloser(bytes.NewBuffer(buf)) } - func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) { api.POST("/upload", auth.JwtMiddleware(cfg.JWTSecret), func(c *gin.Context) { claims := c.MustGet("claims").(jwt.MapClaims) @@ -67,6 +66,7 @@ func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) { fileMeta := types.File{ Owner: uid, + Name: file.Filename, CreatedAt: time.Now(), Size: int64(len(buf)), Mime: fileType.MIME.Value, @@ -85,7 +85,7 @@ func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) { return } - c.JSON(200, gin.H{"message": "file uploaded successfully", "name": fileMeta.ID.String()}) + c.JSON(200, gin.H{"message": "file uploaded successfully", "id": fileMeta.ID.String()}) }) api.DELETE("/:id", auth.JwtMiddleware(cfg.JWTSecret), func(c *gin.Context) { diff --git a/internal/types/types.go b/internal/types/types.go index eeb81c2..1c77dd6 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -32,6 +32,7 @@ type StereoConfig struct { type File struct { ID uuid.UUID `gorm:"type:uuid;primaryKey"` + Name string `gorm:"not null;index"` Owner string `gorm:"not null;index"` Size int64 `gorm:"not null;type:bigint"` CreatedAt time.Time `gorm:"autoCreateTime"`