tmp
This commit is contained in:
parent
bfec6255bc
commit
2f0b38a3fb
@ -14,7 +14,7 @@ type Key string
|
||||
type Value interface {
|
||||
Int() int
|
||||
String() string
|
||||
Float() float32
|
||||
Float() float64
|
||||
Duration() time.Duration
|
||||
}
|
||||
|
||||
@ -22,10 +22,10 @@ type DurationValue time.Duration
|
||||
|
||||
type FloatValue struct {
|
||||
EmptyValue
|
||||
Val float32
|
||||
Val float64
|
||||
}
|
||||
|
||||
func (v FloatValue) Float() float32 {
|
||||
func (v FloatValue) Float() float64 {
|
||||
return v.Val
|
||||
}
|
||||
|
||||
@ -47,8 +47,8 @@ func (v IntValue) Int() int {
|
||||
return v.Val
|
||||
}
|
||||
|
||||
func (v IntValue) Float() float32 {
|
||||
return float32(v.Val)
|
||||
func (v IntValue) Float() float64 {
|
||||
return float64(v.Val)
|
||||
}
|
||||
|
||||
type EmptyValue struct{}
|
||||
@ -61,7 +61,7 @@ func (v EmptyValue) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (v EmptyValue) Float() float32 {
|
||||
func (v EmptyValue) Float() float64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ func (p *staticProvider) GetValue(ctx context.Context, key config.Key) config.Va
|
||||
return config.StringValue{
|
||||
Val: val,
|
||||
}
|
||||
case float32:
|
||||
case float64:
|
||||
return config.FloatValue{
|
||||
Val: val,
|
||||
}
|
||||
|
24
internal/domain/fs_link.go
Normal file
24
internal/domain/fs_link.go
Normal file
@ -0,0 +1,24 @@
|
||||
package domain
|
||||
|
||||
import "fmt"
|
||||
|
||||
type StorageType int
|
||||
|
||||
const (
|
||||
StorageTypeFS StorageType = iota
|
||||
StorageTypeS3
|
||||
)
|
||||
|
||||
const (
|
||||
fslinkTemplate = "fs:///%s"
|
||||
)
|
||||
|
||||
func GetFSConverter(storageType StorageType) func(fslink string) string {
|
||||
switch storageType {
|
||||
default:
|
||||
// TODO s3 converter
|
||||
return func(fslink string) string {
|
||||
return fmt.Sprintf(fslinkTemplate, fslink)
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage"
|
||||
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
|
||||
// "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@ -26,7 +27,7 @@ func NewFilesEngine(
|
||||
|
||||
type File struct {
|
||||
Name string
|
||||
UserID uuid.UUID
|
||||
UserID int64
|
||||
Ext string
|
||||
Type string
|
||||
Size int64
|
||||
@ -38,7 +39,13 @@ func (e *FilesEngine) SaveFile(
|
||||
ctx context.Context,
|
||||
file File,
|
||||
) (uuid.UUID, error) {
|
||||
fileID, err := e.metaStorage.SaveMetadata(ctx, files.FileMetadata{})
|
||||
fileID, err := e.metaStorage.SaveMetadata(ctx, files.FileMetadata{
|
||||
Name: file.Name,
|
||||
UserID: file.UserID,
|
||||
Ext: file.Ext,
|
||||
Type: file.Type,
|
||||
// FSLink: f,
|
||||
})
|
||||
if err != nil {
|
||||
return uuid.Nil, fmt.Errorf("failed to create new file metadata: %w", err)
|
||||
}
|
||||
|
@ -36,4 +36,5 @@ type BlobStorage interface {
|
||||
GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
|
||||
SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
|
||||
DeleteFile(ctx context.Context, id uuid.UUID) error
|
||||
GetFSLink(ctx context.Context, fileID uuid.UUID) (string, error)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user