drive

package
v1.115.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeDrive         = "https://www.googleapis.com/auth/drive"
	ScopeDriveFile     = "https://www.googleapis.com/auth/drive.file"
	ScopeDriveReadonly = "https://www.googleapis.com/auth/drive.readonly"
)
View Source
const Domain = "www.googleapis.com"
View Source
const MaxSimpleUploadBytes = 5 * 1024 * 1024

MaxSimpleUploadBytes is the most content a create or an update sends in one request, which is what Drive takes that way; more goes by a resumable upload, which this client does not make.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(options ...drive_config.Option) *Client

func (*Client) CopyFile added in v1.98.0

func (c *Client) CopyFile(
	ctx context.Context,
	fileId string,
	f *file.File,
	options ...get_file_config.Option,
) (*file.File, error)

CopyFile copies a file, with the metadata f sets in place of the original's: a name, or parents to put the copy elsewhere. A folder cannot be copied.

func (*Client) CreateFile added in v1.98.0

func (c *Client) CreateFile(
	ctx context.Context,
	f *file.File,
	content []byte,
	contentType string,
	options ...get_file_config.Option,
) (*file.File, error)

CreateFile creates a file from its metadata, and its content when content is given. A file with no content is how a folder is made (MimeType file.MimeTypeFolder), or an empty Doc.

A MimeType of one of Drive's own kinds with content of another converts the content: text/plain or text/html made a Doc, text/csv a Sheet.

func (*Client) CreatePermission

func (c *Client) CreatePermission(
	ctx context.Context,
	fileId string,
	p *permission.Permission,
	options ...create_permission_config.Option,
) (*permission.Permission, error)

CreatePermission grants a user, group, domain, or anyone access to the file identified by fileId.

func (*Client) DeleteFile added in v1.98.0

func (c *Client) DeleteFile(ctx context.Context, fileId string, options ...fetch_config.Option) error

DeleteFile deletes a file for good, past the trash: what UpdateFile with Trashed does is what a user would want of their own file, and this is for a file a caller made for itself and has no more use for. A folder's files go with it.

func (*Client) DeletePermission

func (c *Client) DeletePermission(
	ctx context.Context,
	fileId string,
	permissionId string,
	options ...fetch_config.Option,
) error

DeletePermission removes the permission identified by permissionId from the file identified by fileId.

func (*Client) DownloadFile added in v1.98.0

func (c *Client) DownloadFile(ctx context.Context, fileId string, options ...fetch_config.Option) ([]byte, string, error)

DownloadFile retrieves a file's content, with the content type Drive serves it as. A file Drive keeps in a form of its own -- a Doc, a Sheet -- has no content to download and is refused by Drive; ExportFile reads one.

The content is read whole into memory, so a caller wanting a bound reads the file's size first.

func (*Client) ExportFile added in v1.98.0

func (c *Client) ExportFile(ctx context.Context, fileId string, mimeType string, options ...fetch_config.Option) ([]byte, error)

ExportFile retrieves a file Drive keeps in a form of its own converted to the MIME type given: a Doc as text/plain, text/markdown or a PDF, a Sheet as text/csv (its first sheet alone). Drive refuses an export of more than ten megabytes.

func (*Client) GetAbout added in v1.102.0

func (c *Client) GetAbout(ctx context.Context, options ...fetch_config.Option) (*about.About, error)

GetAbout is what Drive says of the user the request is made as: their name and address, as Drive shows them.

func (*Client) GetFile added in v1.98.0

func (c *Client) GetFile(ctx context.Context, fileId string, options ...get_file_config.Option) (*file.File, error)

GetFile retrieves a file's metadata.

func (*Client) GetPermission

func (c *Client) GetPermission(
	ctx context.Context,
	fileId string,
	permissionId string,
	options ...fetch_config.Option,
) (*permission.Permission, error)

GetPermission retrieves the permission identified by permissionId on the file identified by fileId.

func (*Client) ListCommentsPage added in v1.104.0

func (c *Client) ListCommentsPage(
	ctx context.Context,
	fileId string,
	options ...list_comments_config.Option,
) (*comment_list.CommentList, error)

ListCommentsPage retrieves one page of a file's comments, each with its replies, beginning at the options' page token.

func (*Client) ListFilesPage added in v1.98.0

func (c *Client) ListFilesPage(ctx context.Context, options ...list_files_config.Option) (*file_list.FileList, error)

ListFilesPage retrieves one page of the files matching the options, beginning at the options' page token.

func (*Client) ListPermissions

func (c *Client) ListPermissions(
	ctx context.Context,
	fileId string,
	options ...fetch_config.Option,
) ([]*permission.Permission, error)

ListPermissions retrieves all permissions on the file identified by fileId.

func (*Client) UpdateFile added in v1.98.0

func (c *Client) UpdateFile(
	ctx context.Context,
	fileId string,
	f *file.File,
	options ...update_file_config.Option,
) (*file.File, error)

UpdateFile changes the metadata fields f sets, leaving the rest: it renames a file, trashes it or takes it out of the trash, and, with the options' parents, moves it.

func (*Client) UpdateFileContent added in v1.98.0

func (c *Client) UpdateFileContent(
	ctx context.Context,
	fileId string,
	content []byte,
	contentType string,
	options ...update_file_config.Option,
) (*file.File, error)

UpdateFileContent replaces a file's content, keeping its id, its name and its place: Drive keeps what it held before as a revision. Content of a type other than a Doc's or a Sheet's own is converted into one, as on creation.

func (*Client) UpdatePermission

func (c *Client) UpdatePermission(
	ctx context.Context,
	fileId string,
	permissionId string,
	p *permission.Permission,
	options ...update_permission_config.Option,
) (*permission.Permission, error)

UpdatePermission patches the permission identified by permissionId on the file identified by fileId. Only the writable fields (role, allowFileDiscovery, expirationTime) may be set in p.

Jump to

Keyboard shortcuts

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