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.
- https://developers.cloudflare.com/r2/runtime-apis/#bucket-method-definitions
- https://github.com/cloudflare/workers-types/blob/3012f263fb1239825e5f0061b267c8650d01b717/index.d.ts#L1006
func NewBucket ¶
NewBucket returns Bucket for given variable name.
- variable name must be defined in wrangler.toml.
- see example: https://github.com/syumai/workers/tree/main/_examples/r2-image-viewer
- if the given variable name doesn't exist on runtime context, returns error.
- This function panics when a runtime context is not found.
func (*Bucket) Delete ¶
Delete returns the result of `delete` call to Bucket.
- if a network error happens, returns error.
func (*Bucket) Get ¶
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 ¶
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 ¶
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.
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.
Click to show internal directories.
Click to hide internal directories.