Documentation
¶
Index ¶
- Constants
- func WithCredentials(cred aws.CredentialsProvider) func(*s3.Options)
- func WithEndpointURL(u string) func(*s3.Options)
- func WithHTTPClient(c *http.Client) func(*s3.Options)
- func WithPathStyle() func(*s3.Options)
- func WithRegion(region string) func(*s3.Options)
- type AzureClientOption
- type Bucket
- func NewAzureBucket(ctx context.Context, serviceURL, name string, ...) (Bucket, error)
- func NewAzureBucketFromConnectionString(ctx context.Context, connectionString, name string) (Bucket, error)
- func NewGCSBucket(ctx context.Context, name string, opts ...option.ClientOption) (Bucket, error)
- func NewS3Bucket(name string, optFns ...func(*s3.Options)) (Bucket, error)
Constants ¶
const ( // PartSizeUnit is the unit of part size used for Bucket.Put method. PartSizeUnit = 128 << 20 // UploadParts is the number of parts in a multi-part upload on Amazon S3. UploadParts = 4 << 10 )
Variables ¶
This section is empty.
Functions ¶
func WithCredentials ¶
func WithCredentials(cred aws.CredentialsProvider) func(*s3.Options)
WithCredentials specifies a credential provider.
func WithEndpointURL ¶
WithEndpointURL specifies the endpoint of S3 API.
func WithHTTPClient ¶
WithHTTPClient specifies the http.Client to be used.
func WithPathStyle ¶
WithPathStyle specifies to use the path-style API request.
func WithRegion ¶
WithRegion specifies the region of the bucket.
Types ¶
type AzureClientOption ¶ added in v0.35.0
type AzureClientOption func(*azblob.ClientOptions)
AzureClientOption is a function type for configuring Azure Blob Storage client options.
func WithAzureClientOptions ¶ added in v0.35.0
func WithAzureClientOptions(opts *azblob.ClientOptions) AzureClientOption
WithAzureClientOptions allows passing custom Azure client options.
type Bucket ¶
type Bucket interface {
// Put puts an object with `key`. The data is read from `data`.
Put(ctx context.Context, key string, data io.Reader, objectSize int64) error
// Get gets an object by `key`.
Get(ctx context.Context, key string) (io.ReadCloser, error)
// List lists the matching object keys that have `prefix`.
// The prefix argument should end with /. (e.g. "foo/bar/").
// If / is not at the end, both ojbects xx-1/bar and xx-11/bar are taken.
List(ctx context.Context, prefix string) ([]string, error)
}
Bucket represents the interface to access an object storage bucket.
func NewAzureBucket ¶ added in v0.35.0
func NewAzureBucket(ctx context.Context, serviceURL, name string, credential azcore.TokenCredential, optFns ...AzureClientOption) (Bucket, error)
NewAzureBucket creates a Bucket that manages objects in Azure Blob Storage. It uses DefaultAzureCredential for authentication, which supports: - Environment variables (AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET) - Managed Identity - Azure CLI credentials - And other Azure authentication methods
The serviceURL should be in the format: https://<account-name>.blob.core.windows.net/
func NewAzureBucketFromConnectionString ¶ added in v0.35.0
func NewAzureBucketFromConnectionString(ctx context.Context, connectionString, name string) (Bucket, error)
NewAzureBucketFromConnectionString creates a Bucket using an Azure Storage connection string. This is useful for Azurite (local development emulator) and scenarios where connection strings are preferred over credential-based authentication.
Connection string format: "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=<key>;BlobEndpoint=<url>;"
Example for Azurite: "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"