-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add file upload support and utility functions to client library
This update adds file uploading support to the Dioptra client library through a new DioptraFile class, supporting utility functions, and extending the client's post method to accept `data` and `files` arguments. The changes enable users to upload single files, multiple files, or all files within a directory while enforcing strict path validation in the associated filenames to prevent server-side directory traversal attacks. The new functionality includes: - A DioptraFile class that validates filenames to ensure they are normalized, POSIX-compliant relative paths without traversal components (e.g., ".."). - File selection utility functions: - select_files_in_directory: Recursively selects files from a directory with optional regex pattern filtering - select_one_or_more_files: Selects individual files with optional renaming support to handle filename collisions - Extended POST request in the client to handle multipart form data that contains regular form fields and file uploads. All file uploads, whether they're single file or multiple files, are streamed to the server. The DioptraSession implementation for the requests-based client and the Flask test client have both been updated to support the new functionality.
- Loading branch information
1 parent
0140f38
commit db9b5a5
Showing
6 changed files
with
682 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.