2024-11-23 08:52:06 +00:00
|
|
|
package filesengine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
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 int64
|
2024-11-29 05:23:56 +00:00
|
|
|
Ext FileExtension
|
2024-11-23 08:52:06 +00:00
|
|
|
Type string
|
|
|
|
Size int64
|
|
|
|
Data []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *FilesEngine) SaveFile(
|
|
|
|
ctx context.Context,
|
|
|
|
file File,
|
|
|
|
) (int64, error) {
|
2024-11-29 05:23:56 +00:00
|
|
|
e.metaStorage.SaveMetadata(ctx, file.Type, )
|
2024-11-23 08:52:06 +00:00
|
|
|
|
|
|
|
return -1, nil
|
|
|
|
}
|