r2

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket represents interface of Cloudflare Worker's R2 Bucket instance.

func NewBucket

func NewBucket(varName string) (*Bucket, error)

NewBucket returns Bucket for given variable name.

func (*Bucket) Delete

func (r *Bucket) Delete(key string) error

Delete returns the result of `delete` call to Bucket.

  • if a network error happens, returns error.

func (*Bucket) Get

func (r *Bucket) Get(key string) (*Object, error)

Get returns the result of `get` call to Bucket.

  • if the object for given key doesn't exist, returns nil.
  • if a network error happens, returns error.

func (*Bucket) Head

func (r *Bucket) Head(key string) (*Object, error)

Head returns the result of `head` call to Bucket.

  • Body field of *Object is always nil for Head call.
  • if the object for given key doesn't exist, returns nil.
  • if a network error happens, returns error.

func (*Bucket) List

func (r *Bucket) List() (*Objects, error)

List returns the result of `list` call to Bucket.

  • if a network error happens, returns error.

func (*Bucket) Put

func (r *Bucket) Put(key string, value io.ReadCloser, opts *PutOptions) (*Object, error)

Put returns the result of `put` call to Bucket.

  • This method copies all bytes into memory for implementation restriction.
  • Body field of *Object is always nil for Put call.
  • if a network error happens, returns error.

type HTTPMetadata

type HTTPMetadata struct {
	ContentType        string
	ContentLanguage    string
	ContentDisposition string
	ContentEncoding    string
	CacheControl       string
	CacheExpiry        time.Time
}

HTTPMetadata represents metadata of Object.

type Object

type Object struct {
	Key            string
	Version        string
	Size           int
	ETag           string
	HTTPETag       string
	Uploaded       time.Time
	HTTPMetadata   HTTPMetadata
	CustomMetadata map[string]string
	// Body is a body of Object.
	// This value is nil for the result of the `Head` or `Put` method.
	Body io.Reader
	// contains filtered or unexported fields
}

Object represents Cloudflare R2 object.

func (*Object) BodyUsed

func (o *Object) BodyUsed() (bool, error)

type Objects

type Objects struct {
	Objects   []*Object
	Truncated bool
	// Cursor indicates next cursor of Objects.
	//   - This becomes empty string if cursor doesn't exist.
	Cursor            string
	DelimitedPrefixes []string
}

Objects represents Cloudflare R2 objects.

type PutOptions

type PutOptions struct {
	HTTPMetadata   HTTPMetadata
	CustomMetadata map[string]string
	MD5            string
}

PutOptions represents Cloudflare R2 put options.

Jump to

Keyboard shortcuts

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