s3util

package
v0.0.0-...-2ca223a Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C

type C interface {
	context.Context
}

C is an alias to context.Context.

type Client

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

Client gives a client for accessing an S3-compatible storage service.

func NewClient

func NewClient(config *Config, cred *Credential) (*Client, error)

NewClient creates a new client for accessing a storage endpoint with a base path prefix.

func (*Client) BasePath

func (c *Client) BasePath() string

BasePath returns the base path of the client.

func (*Client) BaseURL

func (c *Client) BaseURL() *url.URL

BaseURL returns the S3 URL of the base path.

func (*Client) Copy

func (c *Client) Copy(ctx C, from, to string) error

Copy copies an object.

func (*Client) Delete

func (c *Client) Delete(ctx C, p string) error

Delete deletes an object.

func (*Client) GetBytes

func (c *Client) GetBytes(ctx C, p string) ([]byte, error)

GetBytes gets an object.

func (*Client) GetInto

func (c *Client) GetInto(ctx C, p string, w io.Writer) error

GetInto gets an object and writes its content into w.

func (*Client) GetJSON

func (c *Client) GetJSON(ctx C, p string, v interface{}) error

GetJSON gets a JSON object.

func (*Client) ListAll

func (c *Client) ListAll(ctx C) ([]*minio.ObjectInfo, error)

ListAll lists all objects in the bucket.

func (*Client) PresignGet

func (c *Client) PresignGet(ctx C, p string, exp time.Duration) (
	*url.URL, error,
)

PresignGet presigns a URL for a future GET. The URL expires in d.

func (*Client) PresignPut

func (c *Client) PresignPut(ctx C, p string, exp time.Duration) (
	*url.URL, error,
)

PresignPut presigns a URL for a future PUT. The URL expires in d.

func (*Client) Put

func (c *Client) Put(
	ctx C, p string, r io.Reader, n int64, contentType string,
) error

Put puts an object into the bucket.

func (*Client) PutBytes

func (c *Client) PutBytes(ctx C, p string, data []byte) error

PutBytes saves an object.

func (*Client) PutFile

func (c *Client) PutFile(ctx C, p, fp string) error

PutFile copies a file.

func (*Client) PutJSON

func (c *Client) PutJSON(ctx C, p string, v interface{}) error

PutJSON puts a JSON object.

func (*Client) Stat

func (c *Client) Stat(ctx C, p string) (*minio.ObjectInfo, error)

Stat returns the object info a particular object.

type Config

type Config struct {
	Endpoint string
	Bucket   string
	BasePath string
}

Config contains the configuration for connecting to an S3-compatible storage service.

func (*Config) Host

func (c *Config) Host() string

Host returns the host name of this endpoint config.

func (*Config) URL

func (c *Config) URL() *url.URL

URL returns the S3 URL of this endpoint config.

type Credential

type Credential struct {
	Key    string
	Secret string
}

Credential contains the credentials required for accessing S3-compatible storage.

Jump to

Keyboard shortcuts

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