resumable

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithEndpoint

func WithEndpoint(u string) *option

WithEndpoint changes the Client.endpoint value.

func WithLogger

func WithLogger(l log.Logger) *option

WithLogger changes Client.log value.

Types

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient represents a HTTP client.

type Option

type Option interface {
	Name() string
	Value() interface{}
}

Option represents a configurable parameter of the Uploader.

type ResumableUploader

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

ResumableUploader implements resumable uploads. It will require a SessionStorer to keep already upload session.

func NewResumableUploader

func NewResumableUploader(authenticatedClient HttpClient, store SessionStorer, options ...Option) (*ResumableUploader, error)

NewResumableUploader returns an Uploader or error in case of non valid configuration. The supplied authenticatedClient must have the proper authentication to upload files. The supplied store will be used to keep upload sessions.

Use WithLogger(...) and WithEndpoint(...) to customize configuration.

func (ResumableUploader) UploadFile

func (u ResumableUploader) UploadFile(ctx context.Context, filePath string) (string, error)

UploadFile returns the Google Photos upload token after uploading a file. Any non-2xx status code is an error. Response headers are in error.(*googleapi.Error).Header.

type SessionStorer

type SessionStorer interface {
	Get(fingerprint string) []byte
	Set(fingerprint string, url []byte)
	Delete(fingerprint string)
}

SessionStorer represents an storage to keep resumable uploads.

Jump to

Keyboard shortcuts

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