chunked_upload.go 1.2 KB

1234567891011121314151617181920212223
  1. package models
  2. import "time"
  3. // ChunkedUpload tracks a multi-part upload session. Chunks are stored as
  4. // individual files and merged when the client calls the complete endpoint.
  5. type ChunkedUpload struct {
  6. ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
  7. SessionID string `gorm:"type:uuid;not null;index" json:"sessionId"`
  8. UserID string `gorm:"type:uuid;not null;index" json:"userId"`
  9. ClientID string `gorm:"size:120" json:"clientId"`
  10. Kind string `gorm:"size:20;not null" json:"kind"`
  11. FileName string `gorm:"size:255;not null" json:"fileName"`
  12. MIMEType string `gorm:"size:120" json:"mimeType"`
  13. TotalSize int64 `gorm:"not null" json:"totalSize"`
  14. ChunkSize int `gorm:"not null" json:"chunkSize"`
  15. TotalChunks int `gorm:"not null" json:"totalChunks"`
  16. UploadedChunks int `gorm:"default:0" json:"uploadedChunks"`
  17. StorageDir string `gorm:"size:1000;not null" json:"-"`
  18. Status string `gorm:"size:20;default:'pending'" json:"status"` // pending, completed, expired
  19. CreatedAt time.Time `gorm:"autoCreateTime" json:"createdAt"`
  20. ExpiresAt time.Time `gorm:"not null" json:"expiresAt"`
  21. }