Documentation
¶
Index ¶
- type Client
- func (s *Client) CopyFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error
- func (s *Client) DeleteFile(ctx context.Context, key string) error
- func (s *Client) DownloadFile(ctx context.Context, key string) (storage.DownloadResult, error)
- func (s *Client) GenerateUploadAuth(ctx context.Context, req storage.UploadAuthRequest) (storage.UploadAuthResult, error)
- func (s *Client) IsFileExists(ctx context.Context, key string) (bool, error)
- func (s *Client) MoveFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error
- func (s *Client) UploadFile(ctx context.Context, file io.Reader, key string) (string, error)
- func (s *Client) UploadLocalFile(ctx context.Context, file string, key string) (string, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
urlhandler.Handler
// contains filtered or unexported fields
}
Client provides S3-compatible object storage operations with URL handling capabilities. It uses the MinIO client library to interact with S3 or S3-compatible services.
func NewClient ¶
NewClient creates a new S3-compatible storage client with the provided configuration. It automatically configures the public base URL if not provided and initializes the URL handler for public file access.
func (*Client) CopyFile ¶
func (s *Client) CopyFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error
CopyFile duplicates a file from source to destination key within the S3 bucket.
func (*Client) DeleteFile ¶
DeleteFile removes a file from the S3-compatible storage bucket.
func (*Client) DownloadFile ¶
DownloadFile retrieves a file from S3-compatible storage. Returns the file reader, content type, and content size.
func (*Client) GenerateUploadAuth ¶ added in v0.0.3
func (s *Client) GenerateUploadAuth(ctx context.Context, req storage.UploadAuthRequest) (storage.UploadAuthResult, error)
GenerateUploadAuth creates a presigned PUT URL for direct client uploads to S3. It generates the storage key using configured naming strategy and returns the presigned URL, storage key, and public access URL. The presigned URL expires after 1 hour.
func (*Client) IsFileExists ¶
IsFileExists checks whether a file exists in the S3-compatible storage bucket.
func (*Client) MoveFile ¶
func (s *Client) MoveFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error
MoveFile relocates a file from source to destination key within the S3 bucket. It performs a copy operation followed by deletion of the source file.
func (*Client) UploadFile ¶
UploadFile uploads data from a reader to S3-compatible storage with the specified key.
type Config ¶
type Config struct {
Endpoint string `json:"endpoint"`
AccessKeyID string `json:"access_key"`
SecretAccessKey string `json:"secret"`
Token string `json:"token"`
Bucket string `json:"bucket"`
UseSSL bool `json:"use_ssl"`
PublicBase string `json:"public_base"`
Dir string `json:"dir" yaml:"dir"`
UploadNaming storage.UploadNamingStrategy `json:"upload_naming" yaml:"upload_naming"`
}
Config holds the configuration parameters for S3-compatible object storage.