googledrive

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	SetToken           func(string)
	EnterAuthorization func() string
	// contains filtered or unexported fields
}

Manager is the object that manages Google Drive's credentials, authentication, config, token, etc.

func New

func New(ctx context.Context, path []string, token string, setToken func(token string), enterAuthorization func() string) (*Manager, error)

New creates a new Google Drive "Manager", it's the object that manages authentication, authorization tokens, configs and communication with GoogleDrive.

All files are create within the fixed given `path` (list of strings).

A previously saved authorization `token` can be passed to reuse authorization. If none are available simply pass an empty string here, and a new authorization will be requested.

It requires the following callbacks to be defined:

  • setToken: if the token that gives temporary permission to access Google Drive is updated, this function is called. This token can be saved re-used later on, by passing it in the `token` parameter. If nil, it won't be called, and the token will be "forgotten" at the next instance of the program.
  • enterAuthorization: when a new token is required, the Manager will open the browser with Google to ask for a renewed authentication. Then it will call this function to have a UI for the user to paste the authorization string given by Google.

May return an error if application credentials are wrong.

func (*Manager) ShareImage

func (m *Manager) ShareImage(ctx context.Context, name string, img image.Image) (url string, err error)

ShareImage will create

Jump to

Keyboard shortcuts

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