Documentation ¶
Overview ¶
Package base provides a very low-level interface on top of the B2 v1 API. It is not intended to be used directly.
It currently lacks support for the following APIs:
b2_download_file_by_id b2_list_unfinished_large_files
Index ¶
- Variables
- func Backoff(err error) time.Duration
- func Code(err error) (int, string)
- type AuthOption
- type B2
- type Bucket
- func (b *Bucket) BaseURL() string
- func (b *Bucket) DeleteBucket(ctx context.Context) error
- func (b *Bucket) DownloadFileByName(ctx context.Context, name string, offset, size int64) (*FileReader, error)
- func (b *Bucket) File(id, name string) *File
- func (b *Bucket) GetDownloadAuthorization(ctx context.Context, prefix string, valid time.Duration) (string, error)
- func (b *Bucket) GetUploadURL(ctx context.Context) (*URL, error)
- func (b *Bucket) HideFile(ctx context.Context, name string) (*File, error)
- func (b *Bucket) ListFileNames(ctx context.Context, count int, continuation, prefix, delimiter string) ([]*File, string, error)
- func (b *Bucket) ListFileVersions(ctx context.Context, count int, startName, startID, prefix, delimiter string) ([]*File, string, string, error)
- func (b *Bucket) StartLargeFile(ctx context.Context, name, contentType string, info map[string]string) (*LargeFile, error)
- func (b *Bucket) Update(ctx context.Context) (*Bucket, error)
- type ErrAction
- type File
- type FileChunk
- type FileInfo
- type FilePart
- type FileReader
- type LargeFile
- type LifecycleRule
- type URL
Constants ¶
This section is empty.
Variables ¶
var (
APIBase = "https://api.backblazeb2.com"
)
Functions ¶
Types ¶
type AuthOption ¶
type AuthOption func(*b2Options)
An AuthOption allows callers to choose per-session settings.
func ExpireSomeAuthTokens ¶
func ExpireSomeAuthTokens() AuthOption
ExpireSomeAuthTokens requests intermittent authentication failures from the B2 service.
func FailSomeUploads ¶
func FailSomeUploads() AuthOption
FailSomeUploads requests intermittent upload failures from the B2 service. This is mostly useful for testing.
func ForceCapExceeded ¶
func ForceCapExceeded() AuthOption
ForceCapExceeded requests a cap limit from the B2 service. This causes all uploads to be treated as if they would exceed the configure B2 capacity.
func Transport ¶
func Transport(rt http.RoundTripper) AuthOption
Transport returns an AuthOption that sets the underlying HTTP mechanism.
type B2 ¶
type B2 struct {
// contains filtered or unexported fields
}
B2 holds account information for Backblaze.
func AuthorizeAccount ¶
AuthorizeAccount wraps b2_authorize_account.
func (*B2) CreateBucket ¶
func (b *B2) CreateBucket(ctx context.Context, name, btype string, info map[string]string, rules []LifecycleRule) (*Bucket, error)
CreateBucket wraps b2_create_bucket.
func (*B2) ListBuckets ¶
ListBuckets wraps b2_list_buckets.
type Bucket ¶
type Bucket struct { Name string Type string Info map[string]string LifecycleRules []LifecycleRule // contains filtered or unexported fields }
Bucket holds B2 bucket details.
func (*Bucket) DeleteBucket ¶
DeleteBucket wraps b2_delete_bucket.
func (*Bucket) DownloadFileByName ¶
func (b *Bucket) DownloadFileByName(ctx context.Context, name string, offset, size int64) (*FileReader, error)
DownloadFileByName wraps b2_download_file_by_name.
func (*Bucket) File ¶
File returns a bare File struct, but with the appropriate id and b2 interfaces.
func (*Bucket) GetDownloadAuthorization ¶
func (b *Bucket) GetDownloadAuthorization(ctx context.Context, prefix string, valid time.Duration) (string, error)
GetDownloadAuthorization wraps b2_get_download_authorization.
func (*Bucket) GetUploadURL ¶
GetUploadURL wraps b2_get_upload_url.
func (*Bucket) ListFileNames ¶
func (b *Bucket) ListFileNames(ctx context.Context, count int, continuation, prefix, delimiter string) ([]*File, string, error)
ListFileNames wraps b2_list_file_names.
func (*Bucket) ListFileVersions ¶
func (b *Bucket) ListFileVersions(ctx context.Context, count int, startName, startID, prefix, delimiter string) ([]*File, string, string, error)
ListFileVersions wraps b2_list_file_versions.
type ErrAction ¶
type ErrAction int
ErrAction is an action that a caller can take when any function returns an error.
const ( // ReAuthenticate indicates that the B2 account authentication tokens have // expired, and should be refreshed with a new call to AuthorizeAccount. ReAuthenticate ErrAction = iota // AttemptNewUpload indicates that an upload's authentication token (or URL // endpoint) has expired, and that users should request new ones with a call // to GetUploadURL or GetUploadPartURL. AttemptNewUpload // Retry indicates that the caller should wait an appropriate amount of time, // and then reattempt the RPC. Retry // Punt means that there is no useful action to be taken on this error, and // that it should be displayed to the user. Punt )
type File ¶
type File struct { Name string Size int64 Status string Timestamp time.Time Info *FileInfo // contains filtered or unexported fields }
File represents a B2 file.
func (*File) CompileParts ¶
CompileParts returns a LargeFile that can accept new data. Seen is a mapping of completed part numbers to SHA1 strings; size is the total size of all the completed parts to this point.
func (*File) DeleteFileVersion ¶
DeleteFileVersion wraps b2_delete_file_version.
func (*File) GetFileInfo ¶
GetFileInfo wraps b2_get_file_info.
type FileChunk ¶
type FileChunk struct {
// contains filtered or unexported fields
}
FileChunk holds information necessary for uploading file chunks.
type FileInfo ¶
type FileInfo struct { Name string SHA1 string Size int64 ContentType string Info map[string]string Status string Timestamp time.Time }
FileInfo holds information about a specific file.
type FileReader ¶
type FileReader struct { io.ReadCloser ContentLength int ContentType string SHA1 string ID string Info map[string]string }
FileReader is an io.ReadCloser that downloads a file from B2.
type LargeFile ¶
type LargeFile struct {
// contains filtered or unexported fields
}
LargeFile holds information necessary to implement B2 large file support.
func (*LargeFile) CancelLargeFile ¶
CancelLargeFile wraps b2_cancel_large_file.
func (*LargeFile) FinishLargeFile ¶
FinishLargeFile wraps b2_finish_large_file.