Files
drive/apps/backend/internal/blob/store.go

34 lines
1.1 KiB
Go
Raw Permalink Normal View History

2025-11-26 20:11:12 +00:00
package blob
import (
"context"
"io"
2025-11-28 22:31:00 +00:00
"time"
2025-11-26 20:11:12 +00:00
)
2025-11-28 22:31:00 +00:00
type UploadURLOptions struct {
Duration time.Duration
}
type UpdateOptions struct {
ContentType string
}
2025-11-26 20:11:12 +00:00
type Store interface {
2025-11-29 18:39:21 +00:00
Initialize(ctx context.Context) error
2025-11-26 20:11:12 +00:00
Put(ctx context.Context, key Key, reader io.Reader) error
2025-11-28 22:31:00 +00:00
Update(ctx context.Context, key Key, opts UpdateOptions) error
2025-11-26 20:11:12 +00:00
Delete(ctx context.Context, key Key) error
2025-11-30 01:16:44 +00:00
DeletePrefix(ctx context.Context, prefix Key) error
2025-11-26 20:11:12 +00:00
Move(ctx context.Context, srcKey, dstKey Key) error
2025-11-28 22:31:00 +00:00
Read(ctx context.Context, key Key) (io.ReadCloser, error)
ReadRange(ctx context.Context, key Key, offset, length int64) (io.ReadCloser, error)
ReadSize(ctx context.Context, key Key) (int64, error)
2025-11-30 19:19:54 +00:00
// SupportsDirectUpload returns true if the store allows files to be uploaded directly to the blob store.
SupportsDirectUpload() bool
// GenerateUploadURL generates a URL that can be used to upload a file directly to the blob store. If unsupported, returns an empty string with no error.
GenerateUploadURL(ctx context.Context, key Key, opts UploadURLOptions) (string, error)
2025-11-26 20:11:12 +00:00
}