Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUploadNotFound = errors.New("upload not found") ErrFingerprintNotSet = errors.New("fingerprint not set") )
Functions ¶
This section is empty.
Types ¶
type HttpClient ¶
HttpClient represent a client to make an HTTP request. It is usually implemented by net/http.Client.
type ResumableUploader ¶
type ResumableUploader struct { // Base URL for API requests. // BaseURL should always be specified with a trailing slash. BaseURL string // Logger used to log messages. Logger log.Logger // Store maps an upload's fingerprint with the corresponding upload URL. Store Store // contains filtered or unexported fields }
ResumableUploader implements resumable uploads.
See: https://developers.google.com/photos/library/guides/resumable-uploads.
func NewResumableUploader ¶
func NewResumableUploader(httpClient HttpClient) (*ResumableUploader, error)
NewResumableUploader returns a new client to upload files to Google Photos with resumable capabilities. API methods require authentication, provide an net/http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
func (*ResumableUploader) IsResumeEnabled ¶
func (u *ResumableUploader) IsResumeEnabled() bool
func (*ResumableUploader) UploadFile ¶
func (u *ResumableUploader) UploadFile(ctx context.Context, filePath string) (uploadToken string, err 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 SimpleUploader ¶
type SimpleUploader struct { // Base URL for API requests. // BaseURL should always be specified with a trailing slash. BaseURL string // Logger used to log messages. Logger log.Logger // contains filtered or unexported fields }
SimpleUploader implements a simple uploader to Google Photos.
func NewSimpleUploader ¶
func NewSimpleUploader(httpClient HttpClient) (*SimpleUploader, error)
NewSimpleUploader returns a new client to upload files to Google Photos. API methods require authentication, provide an net/http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
func (*SimpleUploader) UploadFile ¶
func (u *SimpleUploader) UploadFile(ctx context.Context, filePath string) (uploadToken string, err error)
UploadFile uploads a file to Google Photos using upload request. A successful upload request returns an upload token. Use this upload token to create a media item with [media_items.Create].
type Store ¶
type Store interface { Get(fingerprint string) (string, bool) Set(fingerprint string, url string) Delete(fingerprint string) Close() }
Store represents a service to map upload's fingerprint with the corresponding upload URL.