client

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidBaseURL     = errors.New("invalid base URL")
	ErrMissingCredentials = errors.New("missing beamdrop credentials")
	ErrInvalidPath        = errors.New("invalid path")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int            `json:"-"`
	Code       string         `json:"code,omitempty"`
	Category   string         `json:"category,omitempty"`
	Message    string         `json:"message,omitempty"`
	Details    map[string]any `json:"details,omitempty"`
	Retryable  bool           `json:"-"`
	RetryAfter int            `json:"-"`
	Body       []byte         `json:"-"`
}

func (*APIError) Error

func (e *APIError) Error() string

type BucketCreated

type BucketCreated struct {
	Bucket   string `json:"bucket"`
	Created  string `json:"created,omitempty"`
	Exists   bool   `json:"exists,omitempty"`
	Location string `json:"location"`
}

type BucketInfo

type BucketInfo struct {
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
}

type BucketList

type BucketList struct {
	Buckets []BucketInfo `json:"buckets"`
	Count   int          `json:"count"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Client, error)

func (*Client) BucketExists

func (c *Client) BucketExists(ctx context.Context, name string) (bool, error)

func (*Client) CreateBucket

func (c *Client) CreateBucket(ctx context.Context, name string) (*BucketCreated, error)

func (*Client) CreateBucketIfNotExists

func (c *Client) CreateBucketIfNotExists(ctx context.Context, name string) (*BucketCreated, error)

func (*Client) CreatePresignedURL

func (c *Client) CreatePresignedURL(ctx context.Context, request CreatePresignedURLRequest) (*PresignedURL, error)

func (*Client) DeleteBucket

func (c *Client) DeleteBucket(ctx context.Context, name string) error

func (*Client) DeleteObject

func (c *Client) DeleteObject(ctx context.Context, bucket, key string) error

func (*Client) DeletePresignedURL

func (c *Client) DeletePresignedURL(ctx context.Context, token string) error

func (*Client) GetObject

func (c *Client) GetObject(ctx context.Context, bucket, key string) (*ObjectBody, error)

func (*Client) GetPresignedURL

func (c *Client) GetPresignedURL(ctx context.Context, token string) (*PresignedURL, error)

func (*Client) HeadObject

func (c *Client) HeadObject(ctx context.Context, bucket, key string) (*ObjectMetadata, error)

func (*Client) ListBuckets

func (c *Client) ListBuckets(ctx context.Context) (*BucketList, error)

func (*Client) ListObjects

func (c *Client) ListObjects(ctx context.Context, bucket string, options ListObjectsOptions) (*ObjectList, error)

func (*Client) ListPresignedURLs

func (c *Client) ListPresignedURLs(ctx context.Context) (*PresignedURLList, error)

func (*Client) ObjectExists

func (c *Client) ObjectExists(ctx context.Context, bucket, key string) (bool, error)

func (*Client) PresignObjectURL

func (c *Client) PresignObjectURL(method, bucket, key string, expiresAt time.Time) (string, error)

func (*Client) PutObject

func (c *Client) PutObject(ctx context.Context, bucket, key string, body []byte) (*ObjectCreated, error)

func (*Client) PutObjectReader

func (c *Client) PutObjectReader(ctx context.Context, bucket, key string, body io.Reader) (*ObjectCreated, error)

type CommonPrefix

type CommonPrefix struct {
	Prefix string `json:"prefix"`
}

type Config

type Config struct {
	BaseURL     string
	AccessKeyID string
	SecretKey   string
	HTTPClient  *http.Client
	Now         func() time.Time
	UserAgent   string
}

type CreatePresignedURLRequest

type CreatePresignedURLRequest struct {
	Bucket       string `json:"bucket"`
	Key          string `json:"key"`
	Method       string `json:"method,omitempty"`
	ExpiresIn    *int64 `json:"expiresIn,omitempty"`
	MaxDownloads *int   `json:"maxDownloads,omitempty"`
}

type ListObjectsOptions

type ListObjectsOptions struct {
	Prefix    string
	Delimiter string
	MaxKeys   int
}

type ObjectBody

type ObjectBody struct {
	ObjectMetadata
	Body []byte
}

type ObjectCreated

type ObjectCreated struct {
	Bucket string `json:"bucket"`
	Key    string `json:"key"`
	ETag   string `json:"etag"`
	Size   int64  `json:"size"`
	URL    string `json:"url"`
}

type ObjectInfo

type ObjectInfo struct {
	Key          string    `json:"key"`
	Size         int64     `json:"size"`
	LastModified time.Time `json:"lastModified"`
	ETag         string    `json:"etag"`
	ContentType  string    `json:"contentType,omitempty"`
}

type ObjectList

type ObjectList struct {
	Bucket         string         `json:"bucket"`
	Prefix         string         `json:"prefix"`
	Delimiter      string         `json:"delimiter,omitempty"`
	MaxKeys        int            `json:"maxKeys"`
	IsTruncated    bool           `json:"isTruncated"`
	Contents       []ObjectInfo   `json:"contents"`
	CommonPrefixes []CommonPrefix `json:"commonPrefixes,omitempty"`
}

type ObjectMetadata

type ObjectMetadata struct {
	ContentType   string
	ContentLength int64
	ETag          string
	LastModified  string
}

type PresignedURL

type PresignedURL struct {
	ID            uint       `json:"id,omitempty"`
	Token         string     `json:"token"`
	URL           string     `json:"url,omitempty"`
	Bucket        string     `json:"bucket"`
	Key           string     `json:"key"`
	Method        string     `json:"method"`
	ExpiresAt     *time.Time `json:"expiresAt,omitempty"`
	MaxDownloads  *int       `json:"maxDownloads,omitempty"`
	DownloadCount int        `json:"downloadCount,omitempty"`
	CreatedBy     string     `json:"createdBy,omitempty"`
	CreatedAt     time.Time  `json:"createdAt"`
	Message       string     `json:"message,omitempty"`
}

type PresignedURLList

type PresignedURLList struct {
	URLs  []PresignedURL `json:"urls"`
	Count int            `json:"count"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL