RcmEmailAutomation / app /lib /utils /dropbox_client.py
cmoss3's picture
Error handling, confidence scoring, daily brief, deduplicate webhook notifications
0a367ef
Raw
History Blame Contribute Delete
767 Bytes
from __future__ import annotations
import logging
import dropbox
from dropbox.files import WriteMode
logger = logging.getLogger(__name__)
class DropboxClient:
def __init__(self, app_key: str, app_secret: str, refresh_token: str) -> None:
self._dbx = dropbox.Dropbox(
app_key=app_key,
app_secret=app_secret,
oauth2_refresh_token=refresh_token,
)
def upload(self, file_bytes: bytes, dest_path: str) -> str:
"""Upload bytes to dest_path. Returns the path Dropbox assigned (may differ on collision)."""
result = self._dbx.files_upload(
file_bytes,
dest_path,
mode=WriteMode.add,
autorename=True,
)
return result.path_display