dropbox
#
Description#
Plugin to manage a Dropbox account and its files and folders.
Configuration#
dropbox:
# [Required]
# Dropbox API access token. You can get yours by creating an app on
# https://dropbox.com/developers/apps
access_token:
Dependencies#
pip
pip install dropbox
Debian
apt install python3-dropbox
Fedora
yum install python-dropbox
Arch Linux
pacman -S python-dropbox
Actions#
Module reference#
- class platypush.plugins.dropbox.DropboxPlugin(access_token, **kwargs)[source]#
Bases:
Plugin
Plugin to manage a Dropbox account and its files and folders.
- __init__(access_token, **kwargs)[source]#
- Parameters:
access_token (str) – Dropbox API access token. You can get yours by creating an app on https://dropbox.com/developers/apps
- copy(from_path: str, to_path: str, allow_shared_folder=True, autorename=False, allow_ownership_transfer=False)[source]#
Copy a file or folder to a different location in the user’s Dropbox. If the source path is a folder all its contents will be copied.
- Parameters:
from_path – Source path
to_path – Destination path
allow_shared_folder (bool) – If true,
files_copy()
will copy contents in shared folder, otherwiseRelocationError.cant_copy_shared_folder
will be returned iffrom_path
contains shared folder. This field is always true forfiles_move()
.autorename (bool) – If there’s a conflict, have the Dropbox server try to autorename the file to avoid the conflict.
allow_ownership_transfer (bool) – Allow moves by owner even if it would result in an ownership transfer for the content being moved. This does not apply to copies.
- delete(path: str)[source]#
Delete the file or folder at a given path. If the path is a folder, all its contents will be deleted too
- Parameters:
path (str) – Path to be removed
- download(path: str, download_path=None, zip=False)[source]#
Download a file or a zipped directory from a user’s Dropbox.
- Parameters:
- Return type:
- Returns:
A dictionary with keys:
('id', 'name', 'parent_shared_folder_id', 'path', 'size', 'encoding', 'content_hash')
. If download_path is set ‘file’ is also returned. Otherwise ‘content’ will be returned. If it’s a text file then ‘content’ will contain its string representation, otherwise its base64-encoded representation.
- get_account(account_id=None)[source]#
Get the information about a linked Dropbox account
- Parameters:
account_id (str) – account_id. If none is specified then it will retrieve the current user’s account id
- Returns:
dict with the following attributes: account_id, name, email, email_verified, disabled, profile_photo_url, team_member_id
- get_metadata(path: str)[source]#
Get the metadata of the specified path
- Parameters:
path (str) – Path to the resource
- Rtype dict:
- list(folder='')[source]#
Returns the files in a folder
- Parameters:
folder (str) – Folder name (default: root)
- Returns:
dict
- move(from_path: str, to_path: str, allow_shared_folder=True, autorename=False, allow_ownership_transfer=False)[source]#
Move a file or folder to a different location in the user’s Dropbox. If the source path is a folder all its contents will be moved.
- Parameters:
from_path – Source path
to_path – Destination path
allow_shared_folder (bool) – If true,
files_copy()
will copy contents in shared folder, otherwiseRelocationError.cant_copy_shared_folder
will be returned iffrom_path
contains shared folder. This field is always true forfiles_move()
.autorename (bool) – If there’s a conflict, have the Dropbox server try to autorename the file to avoid the conflict.
allow_ownership_transfer (bool) – Allow moves by owner even if it would result in an ownership transfer for the content being moved. This does not apply to copies.
- save(path: str, url: str)[source]#
Save a specified URL into a file in user’s Dropbox. If the given path already exists, the file will be renamed to avoid the conflict (e.g. myfile (1).txt).
- Parameters:
path – Dropbox destination path
url – URL to download
- search(query: str, path='', start=0, max_results=100, content=False)[source]#
Searches for files and folders. Note: Recent changes may not immediately be reflected in search results due to a short delay in indexing.
- Parameters:
path (str) – The path in the user’s Dropbox to search. Should probably be a folder.
query (str) – The string to search for. The search string is split on spaces into multiple tokens. For file name searching, the last token is used for prefix matching (i.e. “bat c” matches “bat cave” but not “batman car”).
start (long) – The starting index within the search results (used for paging).
max_results (long) – The maximum number of search results to return.
content – Search also in files content (default: False)
- Rtype dict:
- Returns:
Dictionary with the following fields:
('matches', 'start')
.
- upload(file=None, text=None, path='/', overwrite=False, autorename=False)[source]#
Create a new file with the contents provided in the request. Do not use this to upload a file larger than 150 MB
- Parameters:
file (str) – File to be uploaded
text (str) – Text content to be uploaded
path (str) – Path in the user’s Dropbox to save the file.
overwrite (bool) – If set, in case of conflict the file will be overwritten (default: append content)
autorename (bool) – If there’s a conflict, as determined by
mode
, have the Dropbox server try to autorename the file to avoid conflict.
- Rtype dict:
- Returns:
Dictionary with the metadata of the uploaded file