Documentation ¶
Overview ¶
Package googledrive provides an abstraction layer over the Google Drive API. It simplifies creating and uploading files to Google Drive by wrapping the complex API calls into more manageable functions.
Index ¶
- Constants
- type Client
- func (c *Client) AssignRoleToAnyoneOnFile(role, fileId string) error
- func (c *Client) AssignRoleToDomainOnFile(role, domain, fileId string) error
- func (c *Client) AssignRoleToGroupOnFile(role, emailAddress, fileId string) error
- func (c *Client) AssignRoleToUserOnFile(role, emailAddress, fileId string) error
- func (c *Client) CreateFolder(folderName string, parentFolders ...string) (string, error)
- func (c *Client) DeleteFile(fileId string) error
- func (c *Client) DownloadFile(fileId, outputFile string) (string, error)
- func (c *Client) GetFileById(fileId string) (*drive.File, error)
- func (c *Client) UpdateFile(fileId string, newContent *os.File) (string, error)
- func (c *Client) UploadFile(file *os.File, parentFolders ...string) (string, error)
Constants ¶
const ( // roles OwnerRole = "owner" OrganizerRole = "organizer" FileOrganizerRole = "fileOrganizer" WriterRole = "writer" CommenterRole = "commenter" ReaderRole = "reader" // grantee types UserGranteeType = "user" GroupGranteeType = "group" DomainGranteeType = "domain" AnyoneGranteeType = "anyone" )
Constant definitions for various roles and grantee types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides functions to interact with Google Drive's file and permission services.
func New ¶
New creates a new Client instance for interacting with Google Drive. It initializes the drive service with the provided context and credentials file.
func (*Client) AssignRoleToAnyoneOnFile ¶
AssignRoleToAnyoneOnFile assigns a specified role to anyone for a file in Google Drive. The role and file ID are specified. Returns an error if the role assignment operation fails.
func (*Client) AssignRoleToDomainOnFile ¶
AssignRoleToDomainOnFile assigns a specified role to a domain for a file in Google Drive. The role, domain, and file ID are specified. Returns an error if the role assignment operation fails.
func (*Client) AssignRoleToGroupOnFile ¶
AssignRoleToGroupOnFile assigns a specified role to a group for a file in Google Drive. The role, group's email address, and file ID are specified. Returns an error if the role assignment operation fails.
func (*Client) AssignRoleToUserOnFile ¶
AssignRoleToUserOnFile assigns a specified role to a user for a file in Google Drive. The role, user's email address, and file ID are specified. Returns an error if the role assignment operation fails.
func (*Client) CreateFolder ¶
CreateFolder creates a new folder in Google Drive with the specified name. The new folder can optionally be created within specified parent folders. Returns the ID of the created folder or an error if the operation fails.
func (*Client) DeleteFile ¶
DeleteFile deletes a file from Google Drive using its file ID. Returns an error if the deletion operation fails.
func (*Client) DownloadFile ¶
DownloadFile downloads a file from Google Drive using its file ID. The downloaded file is saved to the specified outputFile path. Returns the path of the downloaded file or an error if the download operation fails.
func (*Client) GetFileById ¶
GetFileById retrieves the details of a file from Google Drive using its file ID. Returns a drive.File object containing file details or an error if retrieval fails.
func (*Client) UpdateFile ¶
UpdateFile updates the content of an existing file in Google Drive. The file to update is specified by its file ID, and the new content is provided as an os.File pointer. Returns the ID of the updated file or an error if the operation fails.
func (*Client) UploadFile ¶
UploadFile uploads a file to Google Drive. The file to upload is specified as an os.File pointer. The file can optionally be uploaded within specified parent folders. Returns the ID of the uploaded file or an error if the operation fails.