{"modulePath":"github.com/livekit/storage/objects","version":"v0.2.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package objects\n\nPackage objects is the storage interfaces and errors without any provider SDK, for code that implements or accepts them without creating one, such as a fake: the root package imports every provider's SDK.\n\n## Variables\n\n```go\nvar (\n\tErrNotFound = errors.New(\"storage: object not found\")\n\tErrExists   = errors.New(\"storage: object exists\")\n)\n```\n\n## Types\n\n```go\ntype Bucket interface {\n\t// PutObject sends data, which is retried as a whole where a call fails.\n\tPutObject(ctx context.Context, storagePath string, data []byte, opts PutOptions) error\n\t// UploadObject streams body in parts and does not rewind it, so a retry\n\t// needs a new reader. Memory is about the part size times the parts in\n\t// flight: 16 MiB x 6 on S3, 4 MiB x 16 on Azure, one 16 MiB part on GCS and\n\t// OCI, none on AliOSS (one chunked request, up to 5 GB, sent once) and local.\n\tUploadObject(ctx context.Context, storagePath string, body io.Reader, opts PutOptions) error\n\n\tGetObject(ctx context.Context, storagePath string) ([]byte, error)\n\t// GetObjectRange reads length bytes from offset, with offset \u003e= 0 and\n\t// length \u003e 0. A range running past the end returns what the object holds,\n\t// one starting at or past it no bytes.\n\tGetObjectRange(ctx context.Context, storagePath string, offset, length int64) ([]byte, error)\n\t// DownloadObject streams the object to w, which holds part of it when an\n\t// error comes back. An object replaced during a read fails it, with no\n\t// sentinel.\n\tDownloadObject(ctx context.Context, storagePath string, w io.Writer) (int64, error)\n\t// ObjectExists reports a missing object as false, not ErrNotFound.\n\tObjectExists(ctx context.Context, storagePath string) (bool, error)\n\n\t// ListObjects returns every key under prefix, recursively, as full paths,\n\t// in byte order.\n\tListObjects(ctx context.Context, prefix string) ([]string, error)\n\t// DeleteObjects succeeds for paths that hold nothing, as S3's delete does.\n\t// It tries every path, and when some are not deleted fails with a\n\t// *DeleteError naming them; every other path is deleted, and a retry of the\n\t// same paths is safe. GCS, Azure and OCI send one request per path, 16 at\n\t// once.\n\tDeleteObjects(ctx context.Context, storagePaths []string) error\n\n\t// PresignedURL is a GET URL; local returns a file:// URL.\n\tPresignedURL(ctx context.Context, storagePath string, expiration time.Duration) (string, error)\n}\n```\nBucket is object storage for a service that keeps and manages its own objects. A read of a missing object reports ErrNotFound and a write IfAbsent refuses ErrExists; test them with errors.Is. Where a store differs, every backend follows S3.\n\nA key is a store's key as given. The local directory is the exception, as a filesystem: it drops a leading \"/\", cleans \"//\" and \".\" segments, refuses a key that leads out of it, cannot hold both \"a\" and \"a/b\", and keeps its temporary files under names starting with \".upload-\", which it never lists.\n\n```go\ntype DeleteError struct {\n\tFailed map[string]error\n}\n```\nDeleteError is DeleteObjects' failure: Failed holds each path it did not delete, with why. Every other path it was given is deleted.\n\n```go\nfunc (e *DeleteError) Error() string\n```\n\n```go\nfunc (e *DeleteError) Unwrap() []error\n```\nUnwrap is the paths' errors, so errors.Is and errors.As see them.\n\n```go\ntype ErrorWithStatusCode struct {\n\tErr        error\n\tStatusCode int\n\tCode       string\n}\n```\nErrorWithStatusCode carries the HTTP status a store answered with, under ErrNotFound or ErrExists where those apply; find it with errors.As. Code is the store's own name for the error, such as AccessDenied, where it gave one.\n\n```go\nfunc (e *ErrorWithStatusCode) Error() string\n```\n\n```go\nfunc (e *ErrorWithStatusCode) Unwrap() error\n```\n\n```go\ntype PutOptions struct {\n\tContentType string\n\t// IfAbsent fails with ErrExists when the path holds an object, atomically\n\t// where the store honors the condition: an S3-compatible store that ignores\n\t// If-None-Match overwrites, and AliOSS ignores it on a versioned bucket. A\n\t// retry after a lost response can see the caller's own write as existing.\n\tIfAbsent bool\n}\n```\n\n```go\ntype Storage interface {\n\tBucket\n\n\t// UploadFile writes the file at storagePath and returns its location: a\n\t// URL, or the file's path on local.\n\tUploadFile(ctx context.Context, storagePath, filepath string, opts PutOptions) (location string, size int64, err error)\n\t// DownloadFile writes the object to filepath, making its directory, only\n\t// once the whole object is read: a failed download leaves filepath as it\n\t// was.\n\tDownloadFile(ctx context.Context, storagePath, filepath string) (size int64, err error)\n}\n```\nStorage is Bucket and the calls that publish and fetch whole files.\n\n","path":"github.com/livekit/storage/objects","name":"objects","synopsis":"Package objects is the storage interfaces and errors without any provider SDK, for code that implements or accepts them without creating one, such as a fake: the root package imports every provider's SDK.","isRedistributable":true}
