add file storage: metadata schema, minio upload/download, content-type extension mapping
- add files_metadata and files_metadata_connections tables with CRUD helpers - add FileMetadata type and Sha256Hash typedef; replace Media struct - add minio upload, presigned download URL, and key generation - fix bucket existence check to use FileStorageBucketName instead of hardcoded "main" - fix files_metadata_connections table name and trailing comma in DDL - fix column name original -> name in files_metadata schema - add canonical MIME-to-extension map with .unk fallback - add FileDownloadLinkTtl constant (24h)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"math/rand/v2"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -14,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
type Rgba [4]uint8
|
||||
type Sha256Hash [sha256.Size]byte
|
||||
|
||||
func (r Rgba) GetRandom() *Rgba {
|
||||
for i := range r {
|
||||
@@ -103,8 +105,11 @@ type WsAuthMessage struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
type Media struct {
|
||||
Hash string
|
||||
Owner uint32
|
||||
CreatedAt time.Time
|
||||
type FileMetadata struct {
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Connections []uuid.UUID `json:"connections"`
|
||||
Name string `json:"name"`
|
||||
Hash Sha256Hash `json:"hash"`
|
||||
Id uuid.UUID `json:"id"`
|
||||
UploaderId uuid.UUID `json:"uploaderId"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user