googledrive

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrCreateDirectory

func GetOrCreateDirectory(ctx context.Context, client *drive.Service, dirName string, parentID string) (*drive.File, error)

getOrCreateDirectoryID returns the ID of the directory with the given name under the given parent directory, creating it if necessary.

func GetOrCreateFile

func GetOrCreateFile(ctx context.Context, svc *GoogleDriveService, fileName string, media io.Reader, parentID string) (*drive.File, error)

getOrCreateFile returns the ID of the file with the given name under the given parent directory, creating it if necessary.

Types

type Compession

type Compession int
const (
	NoCompression              = -1
	GZipCompression Compession = iota
	ZipCompression
)

type GoogleDriveService

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

func NewGoogleDriveService

func NewGoogleDriveService(client *http.Client, compression ...Compession) *GoogleDriveService

Initialize a new GoogleDriveService. If compression is provided, every file is compressed before being sent.

func (*GoogleDriveService) CreateDirArchive

func (svc *GoogleDriveService) CreateDirArchive(dirname string, paths []string) (archive string, err error)

func (*GoogleDriveService) CreateFileArchive

func (svc *GoogleDriveService) CreateFileArchive(localPath string) (archive string, err error)

func (*GoogleDriveService) MkdirAll

func (svc *GoogleDriveService) MkdirAll(
	dirPath string,
	gdriveParentId string,
) (dirmap map[string]string, dirId string, err error)

Creates all the directories and returns the map of dir segments to Ids Downloads/pdfs -> map["Downloads"]="xhhhsh.......", map["pdfs"]="ufghhd...." dirId -> Innermost directory id.

func (*GoogleDriveService) UploadDirectory

func (svc *GoogleDriveService) UploadDirectory(dirname string, drivePath string) (driveFiles []*drive.File, err error)

Uploads all files in directory syncronously. All intermediate directories are created.

func (*GoogleDriveService) UploadFile

func (svc *GoogleDriveService) UploadFile(localPath string, fileInfo fs.FileInfo, drivePath string) (*drive.File, error)

Jump to

Keyboard shortcuts

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