Documentation ¶
Overview ¶
Package gdrive is a package which provides utilities for manipulating (list, search, upload, download, delete) files on Google Drive. It has special handling for .csv files which it uploads as a Google Sheets documents (and downloads the first visible sheet of Google Sheets documents as .csv text) This can be more simple than using Google's API for common tasks; for anything more complicated use Google's golang sdk directly: https://pkg.go.dev/google.golang.org/api/drive/v3
Index ¶
- type Service
- func (svc *Service) CreateFile(name, parent string, src io.Reader) (*drive.File, error)
- func (svc *Service) CreateFolder(name, parent string) (*drive.File, error)
- func (svc *Service) CreateOrUpdateFile(name, parent string, src io.Reader) (*drive.File, error)
- func (svc *Service) DeleteFile(id string) error
- func (svc *Service) DownloadFile(id string) (*http.Response, error)
- func (svc *Service) FileContents(id string) ([]byte, error)
- func (svc *Service) FilesNamed(name, parent string) ([]*drive.File, error)
- func (svc *Service) FilesService() *drive.FilesService
- func (svc *Service) GetInfo(id string) (*drive.File, error)
- func (svc *Service) Search(q string) ([]*drive.File, error)
- func (svc *Service) UpdateFile(id, name string, src io.Reader) (*drive.File, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wraps drive.FilesService
func NewServiceWithCtx ¶
NewServiceWithCtx creates and wraps a new FilesService with the provided context
func (*Service) CreateFile ¶
CreateFile creats a new file named 'name' in folder with id 'parent' and content read from 'src'. If name has '.csv' extension, then the created file is converted to a Google Sheets document on the drive. If parent is empty, file will be created in user's drive root. If 'src' is nil, creates an empty file. (This will not overwrite any other files with the same name.) https://developers.google.com/drive/api/v3/create-file
func (*Service) CreateFolder ¶
CreateFolder creates a new empty directory named 'name' in folder with id 'parent'. If parent is empty, directory will be created in the authenticated user's drive root. (This will not overwrite any other files with the same name.) https://developers.google.com/drive/api/v3/folder
func (*Service) CreateOrUpdateFile ¶
CreateOrUpdateFile creates a new file named 'name' (with contents of 'src') if it does not already exist in 'parent'; otherwise it replaces the contents of the existing file.
func (*Service) DeleteFile ¶
DeleteFile deletes file identified by 'id'
func (*Service) DownloadFile ¶
DownloadFile returns a http.Response for downloading the contents of file identified by 'id'. If file is a Google Workspace file it is exported as a text format. https://developers.google.com/drive/api/v3/manage-downloads
func (*Service) FileContents ¶
FileContents downloads and returns the contents of the file identified by 'id'
func (*Service) FilesNamed ¶
FilesNamed returns a list of all files named 'name' in the 'parent' folder. If parent is empty, will return files from any files shared with user. If no matching file is found, returns empty list and nil error If an error is encountered it is returned along with any files that were found before encountering the error
func (*Service) FilesService ¶
func (svc *Service) FilesService() *drive.FilesService
FilesService returns a pointer to the wrapped FilesService
func (*Service) Search ¶
Search searches all of the authenticated user's files. 'q' is the search query as documented here: https://developers.google.com/drive/api/v3/ref-search-terms