Documentation
¶
Index ¶
- type GCSStorage
- func (s *GCSStorage) Copy(ctx context.Context, src string, dst string) error
- func (s *GCSStorage) Delete(ctx context.Context, name string) error
- func (s *GCSStorage) DeleteAll(ctx context.Context, prefix string) error
- func (s *GCSStorage) Get(ctx context.Context, name string) (io.ReadCloser, error)
- func (s *GCSStorage) List(ctx context.Context, prefix string) ([]*ObjectInfo, error)
- func (s *GCSStorage) Move(ctx context.Context, src string, dst string) error
- func (s *GCSStorage) Name() string
- func (s *GCSStorage) PathJoin(elem ...string) string
- func (s *GCSStorage) Put(ctx context.Context, name string, r io.Reader, opts *PutOptions) (int64, error)
- type LocalStorage
- func (s *LocalStorage) Copy(ctx context.Context, src string, dst string) error
- func (s *LocalStorage) Delete(ctx context.Context, name string) error
- func (s *LocalStorage) DeleteAll(ctx context.Context, prefix string) error
- func (s *LocalStorage) Get(ctx context.Context, name string) (io.ReadCloser, error)
- func (s *LocalStorage) List(ctx context.Context, prefix string) ([]*ObjectInfo, error)
- func (s *LocalStorage) Move(ctx context.Context, src string, dst string) error
- func (s *LocalStorage) Name() string
- func (s *LocalStorage) PathJoin(elem ...string) string
- func (s *LocalStorage) Put(ctx context.Context, name string, r io.Reader, opts *PutOptions) (int64, error)
- type ObjectInfo
- type PutOptions
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GCSStorage ¶
type GCSStorage struct {
// contains filtered or unexported fields
}
GCSStorage implements the Storage interface for Google Cloud Storage (GCS).
func NewGCSStorage ¶
func NewGCSStorage(client *storage.Client, bucketName string) *GCSStorage
NewGCSStorage creates a new GCSStorage instance with the specified client, bucket name.
func (*GCSStorage) Delete ¶
func (s *GCSStorage) Delete(ctx context.Context, name string) error
Delete deletes the object with the specified name.
func (*GCSStorage) DeleteAll ¶
func (s *GCSStorage) DeleteAll(ctx context.Context, prefix string) error
DeleteAll deletes all objects matching the specified prefix.
func (*GCSStorage) Get ¶
func (s *GCSStorage) Get(ctx context.Context, name string) (io.ReadCloser, error)
Get returns an io.ReadCloser to read the object with the specified name.
func (*GCSStorage) List ¶
func (s *GCSStorage) List(ctx context.Context, prefix string) ([]*ObjectInfo, error)
List returns a list of objects matching the specified prefix.
func (*GCSStorage) Move ¶
Move moves (renames) an object from the source path to the destination path.
func (*GCSStorage) Name ¶
func (s *GCSStorage) Name() string
Name returns the bucketName (identifier) of this storage.
func (*GCSStorage) PathJoin ¶
func (s *GCSStorage) PathJoin(elem ...string) string
PathJoin joins multiple path elements according to the storage's format.
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, name string) *LocalStorage
NewLocalStorage creates a new LocalStorage instance with the specified root directory and name.
func (*LocalStorage) Delete ¶
func (s *LocalStorage) Delete(ctx context.Context, name string) error
Delete deletes the object with the specified name.
func (*LocalStorage) DeleteAll ¶
func (s *LocalStorage) DeleteAll(ctx context.Context, prefix string) error
DeleteAll deletes all objects matching the specified prefix.
func (*LocalStorage) Get ¶
func (s *LocalStorage) Get(ctx context.Context, name string) (io.ReadCloser, error)
Get returns an io.ReadCloser to read the object with the specified name.
func (*LocalStorage) List ¶
func (s *LocalStorage) List(ctx context.Context, prefix string) ([]*ObjectInfo, error)
List returns a list of objects matching the specified prefix.
func (*LocalStorage) Move ¶
Move moves (renames) an object from the source path to the destination path.
func (*LocalStorage) Name ¶
func (s *LocalStorage) Name() string
Name returns the name (identifier) of this storage.
func (*LocalStorage) PathJoin ¶
func (s *LocalStorage) PathJoin(elem ...string) string
PathJoin joins multiple path elements according to the storage's format.
type ObjectInfo ¶
type ObjectInfo struct {
// Name is the full path (name) of the object.
Name string
// Size is the data size of the object in bytes.
Size int64
// UpdatedAt is the time when the object was last updated.
UpdatedAt time.Time
// Metadata is the metadata associated with the object.
Metadata map[string]string
}
ObjectInfo holds detailed information about an object in the storage.
type PutOptions ¶
type PutOptions struct {
// ContentType specifies the MIME type of the object.
ContentType string
// Metadata is arbitrary metadata associated with the object.
Metadata map[string]string
}
PutOptions holds optional settings for saving an object.
type Storage ¶
type Storage interface {
// Name returns the name (identifier) of this storage.
Name() string
// Get returns an io.ReadCloser to read the object with the specified name.
Get(ctx context.Context, name string) (io.ReadCloser, error)
// Put saves data to the storage with the specified name.
Put(ctx context.Context, name string, r io.Reader, opts *PutOptions) (int64, error)
// List returns a list of objects matching the specified prefix.
List(ctx context.Context, prefix string) ([]*ObjectInfo, error)
// Copy copies an object from the source path to the destination path.
Copy(ctx context.Context, src string, dst string) error
// Move moves (renames) an object from the source path to the destination path.
Move(ctx context.Context, src string, dst string) error
// Delete deletes the object with the specified name.
Delete(ctx context.Context, name string) error
// DeleteAll deletes all objects matching the specified prefix.
DeleteAll(ctx context.Context, prefix string) error
// PathJoin joins multiple path elements according to the storage's format.
PathJoin(elem ...string) string
}
Storage defines the interface for a set of operations on object storage.