mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Implement s3 storage.
Use uuid as file id.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
type File struct {
|
||||
gorm.Model
|
||||
UUID string `gorm:"uniqueIndex;not null"`
|
||||
Filename string
|
||||
Description string
|
||||
StorageKey string
|
||||
@@ -16,17 +17,18 @@ type File struct {
|
||||
Resource Resource `gorm:"foreignKey:ResourceID"`
|
||||
UserID uint
|
||||
User User `gorm:"foreignKey:UserID"`
|
||||
Size int64
|
||||
}
|
||||
|
||||
type FileView struct {
|
||||
ID uint `json:"id"`
|
||||
ID string `json:"id"`
|
||||
Filename string `json:"filename"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
func (f *File) ToView() *FileView {
|
||||
return &FileView{
|
||||
ID: f.ID,
|
||||
ID: f.UUID,
|
||||
Filename: f.Filename,
|
||||
Description: f.Description,
|
||||
}
|
||||
|
Reference in New Issue
Block a user