feat: file uploads

This commit is contained in:
2025-03-16 06:50:11 -04:00
parent 50c8d18df9
commit f6d75964c1
25 changed files with 1393 additions and 320 deletions

View File

@ -0,0 +1,12 @@
package models
type File struct {
ID uint32 `gorm:"primaryKey"`
Name string
Data []byte
// User
UserID uint
User User
}

View File

@ -1,8 +1,32 @@
package models
import (
"fmt"
userv1 "github.com/spotdemo4/trevstack/server/internal/services/user/v1"
)
type User struct {
ID uint32 `gorm:"primaryKey"`
Username string
Password string
// Profile picture
ProfilePictureID *uint
ProfilePicture *File
}
func (u User) ToConnectV1() *userv1.User {
var ppid *string
if u.ProfilePicture != nil {
id := fmt.Sprintf("/file/%d", u.ProfilePicture.ID)
ppid = &id
}
return &userv1.User{
Id: u.ID,
Username: u.Username,
ProfilePicture: ppid,
}
}