Documentation ¶
Index ¶
- func GetOrCreateDirectory(ctx context.Context, client *drive.Service, dirName string, parentID string) (*drive.File, error)
- func GetOrCreateFile(ctx context.Context, svc *GoogleDriveService, fileName string, media io.Reader, ...) (*drive.File, error)
- type Compession
- type GoogleDriveService
- func (svc *GoogleDriveService) CreateDirArchive(dirname string, paths []string) (archive string, err error)
- func (svc *GoogleDriveService) CreateFileArchive(localPath string) (archive string, err error)
- func (svc *GoogleDriveService) MkdirAll(dirPath string, gdriveParentId string) (dirmap map[string]string, dirId string, err error)
- func (svc *GoogleDriveService) UploadDirectory(dirname string, drivePath string) (driveFiles []*drive.File, err error)
- func (svc *GoogleDriveService) UploadFile(localPath string, fileInfo fs.FileInfo, drivePath string) (*drive.File, error)
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 ¶
Click to show internal directories.
Click to hide internal directories.