photos

package
v0.0.0-...-be30e72 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Endpoint = google.Endpoint

Endpoint is an URL of Google Photos Library API.

View Source
var Scopes = []string{photoslibrary.PhotoslibraryScope}

Scopes is a set of OAuth scopes.

Functions

This section is empty.

Types

type AddResult

type AddResult struct {
	MediaItem *photoslibrary.MediaItem
	Error     error
}

AddResult represents result of the add operation.

type FileUploadItem

type FileUploadItem string

FileUploadItem represents a local file.

func (FileUploadItem) Name

func (m FileUploadItem) Name() string

Name returns the filename.

func (FileUploadItem) Open

func (m FileUploadItem) Open() (io.ReadCloser, int64, error)

Open returns a stream. Caller should close it finally.

func (FileUploadItem) String

func (m FileUploadItem) String() string

type HTTPUploadItem

type HTTPUploadItem struct {
	Client  *http.Client
	Request *http.Request
}

HTTPUploadItem represents a remote file.

func (*HTTPUploadItem) Name

func (m *HTTPUploadItem) Name() string

Name returns the filename.

func (*HTTPUploadItem) Open

func (m *HTTPUploadItem) Open() (io.ReadCloser, int64, error)

Open returns a stream. Caller should close it finally.

func (*HTTPUploadItem) String

func (m *HTTPUploadItem) String() string

type ListAlbumsFunc

type ListAlbumsFunc func(albums []*photoslibrary.Album, stop func())

ListAlbumsFunc is called for each response of 50 albums. If this calls stop, ListAlbums stops the loop.

type Photos

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

Photos provides service for manage albums and uploading media items.

func New

func New(client *http.Client) (*Photos, error)

New creates a Photos.

func (*Photos) AddToAlbum

func (p *Photos) AddToAlbum(ctx context.Context, title string, uploadItems []UploadItem) ([]*AddResult, error)

AddToAlbum adds the items to the album. This method tries uploading all items and ignores any error. If no item could be uploaded, this method returns an error.

func (*Photos) AddToLibrary

func (p *Photos) AddToLibrary(ctx context.Context, uploadItems []UploadItem) []*AddResult

AddToLibrary adds the items to the library. This method tries uploading all items and ignores any error. If no item could be uploaded, this method returns an error.

func (*Photos) CreateAlbum

func (p *Photos) CreateAlbum(ctx context.Context, title string, uploadItems []UploadItem) ([]*AddResult, error)

CreateAlbum creates an album with the media items. This method tries uploading all items and ignores any error. If no item could be uploaded, this method returns an error.

func (*Photos) FindAlbumByTitle

func (p *Photos) FindAlbumByTitle(ctx context.Context, title string) (*photoslibrary.Album, error)

FindAlbumByTitle returns the album which has the title. If the album was not found, it returns nil. If any error occurred, it returns the error.

func (*Photos) ListAlbums

func (p *Photos) ListAlbums(ctx context.Context, callback ListAlbumsFunc) error

ListAlbums gets a list of albums. It calls the function for each 50 albums.

type UploadItem

type UploadItem interface {
	internal.UploadItem
}

UploadItem represents an uploadable item.

Directories

Path Synopsis
Package internal is a thin wrapper of Google Photos Library API, providing error handling and retrying.
Package internal is a thin wrapper of Google Photos Library API, providing error handling and retrying.

Jump to

Keyboard shortcuts

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