mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
feat: add blob store Initialize method
This commit is contained in:
@@ -24,6 +24,10 @@ func NewFSStore(config FSStoreConfig) *FSStore {
|
||||
return &FSStore{config: config}
|
||||
}
|
||||
|
||||
func (s *FSStore) Initialize(ctx context.Context) error {
|
||||
return os.MkdirAll(s.config.Root, 0755)
|
||||
}
|
||||
|
||||
func (s *FSStore) GenerateUploadURL(ctx context.Context, key Key, opts UploadURLOptions) (string, error) {
|
||||
return s.config.UploadURL, nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ type UpdateOptions struct {
|
||||
}
|
||||
|
||||
type Store interface {
|
||||
Initialize(ctx context.Context) error
|
||||
GenerateUploadURL(ctx context.Context, key Key, opts UploadURLOptions) (string, error)
|
||||
Put(ctx context.Context, key Key, reader io.Reader) error
|
||||
Update(ctx context.Context, key Key, opts UpdateOptions) error
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package drexa
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/get-drexa/drexa/internal/auth"
|
||||
@@ -29,6 +30,11 @@ func NewServer(c Config) (*fiber.App, error) {
|
||||
return nil, fmt.Errorf("unknown storage backend: %s", c.Storage.Backend)
|
||||
}
|
||||
|
||||
err := blobStore.Initialize(context.Background())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to initialize blob store: %w", err)
|
||||
}
|
||||
|
||||
// Initialize key resolver based on config
|
||||
var keyResolver virtualfs.BlobKeyResolver
|
||||
switch c.Storage.Mode {
|
||||
|
||||
Reference in New Issue
Block a user