package filesengine import ( "context" "fmt" "git.optclblast.xyz/draincloud/draincloud-core/internal/storage" "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files" "github.com/google/uuid" ) type FilesEngine struct { blobStorage storage.BlobStorage metaStorage storage.MetaStorage } func NewFilesEngine( blobStorage storage.BlobStorage, metaStorage storage.MetaStorage, ) *FilesEngine { return &FilesEngine{ blobStorage: blobStorage, metaStorage: metaStorage, } } type File struct { Name string UserID uuid.UUID Ext string Type string Size int64 Data []byte } // TODO save file func (e *FilesEngine) SaveFile( ctx context.Context, file File, ) (uuid.UUID, error) { fileID, err := e.metaStorage.SaveMetadata(ctx, files.FileMetadata{}) if err != nil { return uuid.Nil, fmt.Errorf("failed to create new file metadata: %w", err) } if err = e.blobStorage.SaveBlob(ctx, fileID, file.Data); err != nil { return uuid.Nil, fmt.Errorf("failed to save file data: %w", err) } return fileID, nil }