Skip to content

Commit

Permalink
Merge pull request #66 from opengisch/check_for_forbidden_characters
Browse files Browse the repository at this point in the history
Adding validator for files to upload on SDK
  • Loading branch information
SeqLaz authored Oct 3, 2024
2 parents 2d6c74f + ff0538a commit bc4413a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qfieldcloud_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ idna>=3.4
requests>=2.31.0
tqdm>=4.65.0
urllib3>=2.0.7
pathvalidate>=3.2.1

0 comments on commit bc4413a

Please sign in to comment.