Documentation
¶
Index ¶
- func DetectMIME(content []byte) string
- type LocalStorage
- func (s *LocalStorage) Copy(ctx context.Context, src, dest string) error
- func (s *LocalStorage) Delete(ctx context.Context, path string) error
- func (s *LocalStorage) Exists(ctx context.Context, path string) (bool, error)
- func (s *LocalStorage) Get(ctx context.Context, path string) ([]byte, error)
- func (s *LocalStorage) Move(ctx context.Context, src, dest string) error
- func (s *LocalStorage) Put(ctx context.Context, path string, content []byte) error
- func (s *LocalStorage) SignedURL(ctx context.Context, path string, expiresIn time.Duration) (string, error)
- func (s *LocalStorage) URL(path string) (string, error)
- type MemoryStorage
- func (s *MemoryStorage) Copy(ctx context.Context, src, dest string) error
- func (s *MemoryStorage) Delete(ctx context.Context, path string) error
- func (s *MemoryStorage) Exists(ctx context.Context, path string) (bool, error)
- func (s *MemoryStorage) Get(ctx context.Context, path string) ([]byte, error)
- func (s *MemoryStorage) Move(ctx context.Context, src, dest string) error
- func (s *MemoryStorage) Put(ctx context.Context, path string, content []byte) error
- func (s *MemoryStorage) SignedURL(ctx context.Context, path string, expiresIn time.Duration) (string, error)
- func (s *MemoryStorage) URL(path string) (string, error)
- type S3Storage
- func (s *S3Storage) Copy(ctx context.Context, src, dest string) error
- func (s *S3Storage) Delete(ctx context.Context, path string) error
- func (s *S3Storage) Exists(ctx context.Context, path string) (bool, error)
- func (s *S3Storage) Get(ctx context.Context, path string) ([]byte, error)
- func (s *S3Storage) Move(ctx context.Context, src, dest string) error
- func (s *S3Storage) Put(ctx context.Context, path string, content []byte) error
- func (s *S3Storage) SignedURL(ctx context.Context, path string, expiresIn time.Duration) (string, error)
- func (s *S3Storage) URL(path string) (string, error)
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectMIME ¶
DetectMIME detects the MIME type of a byte slice.
Types ¶
type LocalStorage ¶
type LocalStorage struct {
// contains filtered or unexported fields
}
LocalStorage implements the Storage interface for the local filesystem.
func NewLocalStorage ¶
func NewLocalStorage(rootDir string) *LocalStorage
NewLocalStorage creates a new LocalStorage.
func (*LocalStorage) Copy ¶
func (s *LocalStorage) Copy(ctx context.Context, src, dest string) error
Copy copies a file on the local filesystem.
func (*LocalStorage) Delete ¶
func (s *LocalStorage) Delete(ctx context.Context, path string) error
Delete removes a file from the local filesystem.
func (*LocalStorage) Move ¶
func (s *LocalStorage) Move(ctx context.Context, src, dest string) error
Move moves a file on the local filesystem.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage implements the Storage interface in-memory for test_util.
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a new MemoryStorage.
func (*MemoryStorage) Copy ¶
func (s *MemoryStorage) Copy(ctx context.Context, src, dest string) error
func (*MemoryStorage) Delete ¶
func (s *MemoryStorage) Delete(ctx context.Context, path string) error
func (*MemoryStorage) Move ¶
func (s *MemoryStorage) Move(ctx context.Context, src, dest string) error
type S3Storage ¶
type S3Storage struct {
// contains filtered or unexported fields
}
S3Storage implements the Storage interface for S3-compatible APIs.
func NewS3Storage ¶
NewS3Storage creates a new S3Storage.
func (*S3Storage) SignedURL ¶
func (s *S3Storage) SignedURL(ctx context.Context, path string, expiresIn time.Duration) (string, error)
SignedURL returns a presigned URL for the file. IMPORTANT: This method does not perform authorization. Any application-level endpoint calling this MUST verify the user has access to the requested path.
type Storage ¶
type Storage interface {
Put(ctx context.Context, path string, content []byte) error
Get(ctx context.Context, path string) ([]byte, error)
Delete(ctx context.Context, path string) error
URL(path string) (string, error)
SignedURL(ctx context.Context, path string, expiresIn time.Duration) (string, error)
Exists(ctx context.Context, path string) (bool, error)
Copy(ctx context.Context, src, dest string) error
Move(ctx context.Context, src, dest string) error
}
Storage defines the interface for file storage.