Ir para o conteúdo

botcity.plugins.googledrive.plugin.BotGoogleDrivePlugin

__init__(self, credentials_file_path, support_all_drives=True) special

BotGoogleDrivePlugin.

Parameters:

Name Type Description Default
credentials_file_path str

The path of the credentials json file obtained at Google Cloud Platform.

required
support_all_drives bool

If True, the plugin will support all drives.

True

create_folder(self, folder_name, parent_folder_id=None)

Create a folder on Google Drive.

Parameters:

Name Type Description Default
folder_name str

Name of the folder to be created.

required

Returns:

Type Description
str

The id of the created folder.

delete_file(self, file_id)

Delete a file stored on Google Drive.

Parameters:

Name Type Description Default
file_id str

Id of the file to be deleted.

required

download_file(self, file_id, file_path)

Download a file stored on Google Drive.

Parameters:

Name Type Description Default
file_id str

Id of the file to be downloaded.

required
file_path str

Path where the file will be saved.

required

export_file(self, file_id, file_path, mime_type)

Download a Google Workspace Document stored on Google Drive.

Parameters:

Name Type Description Default
file_id str

Id of the file to be downloaded.

required
file_path str

Path where the file will be saved.

required
mime_type str

MIME type corresponding to the Google Workspace document to be downloaded.

required

get_files_from_parent_folder(self, parent_folder_id, include_filename=False)

Searches for every file and folder inside a parent folder.

Parameters:

Name Type Description Default
parent_folder_id str

The id of the folder containing the files to be returned.

required
include_filename bool

The function will return a list of tuples with the id and name of the files.

False

Returns:

Type Description
List

The list of found ids.

search_file_by_name(self, filename)

Searches for a file on google drive by the file name.

Parameters:

Name Type Description Default
filename str

The exact name of the file to be fetched.

required

Returns:

Type Description
str

The id of the file found.

search_folder_by_name(self, folder_name)

Searches for a folder on google drive by the folder name.

Parameters:

Name Type Description Default
folder_name str

The exact name of the folder to be fetched.

required

Returns:

Type Description
str

The id of the folder found.

upload_file(self, file_path, file_name, parent_folder_id=None, mime_type=None)

Upload a file on Google Drive.

Parameters:

Name Type Description Default
file_path str

Path to the file to be used.

required
file_name str

Name of the file that will be displayed on the drive.

required
parent_folder_id Optional[str]

Id of the folder that will receive the file, otherwise it will be uploaded to the main folder.

None
mime_type Optional[str]

The MIME type corresponding to the file if necessary.

None

Returns:

Type Description
str

The uploaded file id or None.