feat: add blob store Initialize method

This commit is contained in:
2025-11-29 18:39:21 +00:00
parent ab4c14bc09
commit 42b805fbd1
3 changed files with 11 additions and 0 deletions

View File

@@ -24,6 +24,10 @@ func NewFSStore(config FSStoreConfig) *FSStore {
return &FSStore{config: config} 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) { func (s *FSStore) GenerateUploadURL(ctx context.Context, key Key, opts UploadURLOptions) (string, error) {
return s.config.UploadURL, nil return s.config.UploadURL, nil
} }

View File

@@ -15,6 +15,7 @@ type UpdateOptions struct {
} }
type Store interface { type Store interface {
Initialize(ctx context.Context) error
GenerateUploadURL(ctx context.Context, key Key, opts UploadURLOptions) (string, error) GenerateUploadURL(ctx context.Context, key Key, opts UploadURLOptions) (string, error)
Put(ctx context.Context, key Key, reader io.Reader) error Put(ctx context.Context, key Key, reader io.Reader) error
Update(ctx context.Context, key Key, opts UpdateOptions) error Update(ctx context.Context, key Key, opts UpdateOptions) error

View File

@@ -1,6 +1,7 @@
package drexa package drexa
import ( import (
"context"
"fmt" "fmt"
"github.com/get-drexa/drexa/internal/auth" "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) 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 // Initialize key resolver based on config
var keyResolver virtualfs.BlobKeyResolver var keyResolver virtualfs.BlobKeyResolver
switch c.Storage.Mode { switch c.Storage.Mode {