diff --git a/qfieldcloud_sdk/sdk.py b/qfieldcloud_sdk/sdk.py index a384a53..01fd338 100644 --- a/qfieldcloud_sdk/sdk.py +++ b/qfieldcloud_sdk/sdk.py @@ -14,6 +14,8 @@ from .interfaces import QfcException, QfcRequest, QfcRequestException from .utils import calc_etag, log +from pathvalidate import is_valid_filepath + logger = logging.getLogger(__file__) @@ -493,9 +495,15 @@ def upload_file( show_progress: Whether to display a progress bar during upload. job_id: The job ID, required if `upload_type` is PACKAGE. Defaults to an empty string. + Raises: + pathvalidate.ValidationError: Raised when the uploaded file does not have a valid filename. + Returns: The response object from the upload request. """ + # if the filepath is invalid, it will throw a new error `pathvalidate.ValidationError` + is_valid_filepath(str(local_filename)) + with open(local_filename, "rb") as local_file: upload_file = local_file if show_progress: diff --git a/requirements.txt b/requirements.txt index 0905324..7f57a4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ idna>=3.4 requests>=2.31.0 tqdm>=4.65.0 urllib3>=2.0.7 +pathvalidate>=3.2.1