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:
2026-04-14 18:55:22 +02:00
parent 39a28ee888
commit 48d3c6f857
4 changed files with 135 additions and 17 deletions
+9 -4
View File
@@ -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"`
}