mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
feat: impl upload service
This commit is contained in:
@@ -9,11 +9,16 @@ import (
|
||||
)
|
||||
|
||||
type BlobKeyResolver interface {
|
||||
KeyMode() blob.KeyMode
|
||||
Resolve(ctx context.Context, node *Node) (blob.Key, error)
|
||||
}
|
||||
|
||||
type FlatKeyResolver struct{}
|
||||
|
||||
func (r *FlatKeyResolver) KeyMode() blob.KeyMode {
|
||||
return blob.KeyModeStable
|
||||
}
|
||||
|
||||
func (r *FlatKeyResolver) Resolve(ctx context.Context, node *Node) (blob.Key, error) {
|
||||
if node.BlobKey == "" {
|
||||
id, err := uuid.NewV7()
|
||||
@@ -29,10 +34,15 @@ type HierarchicalKeyResolver struct {
|
||||
db *bun.DB
|
||||
}
|
||||
|
||||
func (r *HierarchicalKeyResolver) KeyMode() blob.KeyMode {
|
||||
return blob.KeyModeDerived
|
||||
}
|
||||
|
||||
func (r *HierarchicalKeyResolver) Resolve(ctx context.Context, node *Node) (blob.Key, error) {
|
||||
path, err := buildNodeAbsolutePath(ctx, r.db, node.ID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return blob.Key(path), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user