diff --git a/internal/photos/api/upload.go b/internal/photos/api/upload.go index 7b3416f..70686f3 100644 --- a/internal/photos/api/upload.go +++ b/internal/photos/api/upload.go @@ -26,22 +26,12 @@ var ( // Model type File struct { - ID uint32 `gorm:"primary_key" json:"id"` - Name string `gorm:"not null" json:"name"` - Checksum string `gorm:"unique;size:44;not null"` - Size uint64 `gorm:"not null"` - Author *Account `gorm:"constraint:OnDelete:SET NULL,OnUpdate:CASCADE" json:"author"` - AuthorId *uint32 `json:"-"` - Chunks []*FileChunk `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` -} - -type FileChunk struct { - FileId uint32 - File *File `gorm:"constraint:OnDelete:CASCADE,OnUpdate:CASCADE"` - Part uint32 + ID uint32 `gorm:"primary_key" json:"id"` + Name string `gorm:"not null" json:"name"` Checksum string `gorm:"unique;size:44;not null"` + Size uint64 `gorm:"not null"` + Author *Account `gorm:"constraint:OnDelete:SET NULL,OnUpdate:CASCADE" json:"author"` + AuthorId *uint32 `json:"-"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } @@ -176,6 +166,7 @@ func (s *Service) UploadComplete(c *gin.Context) { func (s *Service) UploadInit() { upload := s.Gin.Group("/upload") + upload.Use(s.RequireSession) // start upload.POST("", s.UploadCreate)