-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature implementation/#2189 Add support for uploading nested folders #2206
base: develop
Are you sure you want to change the base?
Conversation
taipy/gui/viselements.json
Outdated
@@ -1227,6 +1227,12 @@ | |||
"default_value": "False", | |||
"doc": "If set to True, multiple files can be uploaded." | |||
}, | |||
{ | |||
"name": "webkitdirectory", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad name ... who cares about webkit in python ?
allow_folder_selection
that would translate to allowFolderSelection
?
What does our naming expert @FabienLelaquais says ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to get the word nested
, like nested_folder_upload
in there, as it captures what the code does. It not only uploads the content of folder, but imitates the structure of the folder in the directory it is uploaded to, like:
/tmp
| -- file1
| -- dir2
|-- file1
|-- file2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a nice added benefit but I think the main feature is to be able to select a folder and everything it contains, no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for me, because I need the structure to be preserved for a project, but I can see, why this is mostly the usecase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad name ... who cares about webkit in python ?
allow_folder_selection
that would translate toallowFolderSelection
? What does our naming expert @FabienLelaquais says ?
What about files_only
, defaults to True?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would solve it the other way round. In my eyes, it sounds a bit like files_only=false
would allow the selection of files and folders (which is not the case). Im currently working with selectFolder = false
, but I don't have a strong preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another suggestion from my side: I just lost hours to debugging and it was the naming conventions. I.e. I didn't snake_case my variable name for python scripts, because I thought, that I would do that later to aid me connect the variables in my head during repeated changes. I did not realize until now that the snake_case is necessary for the variable to be adequately converted into the right typescript camelCase. I think this could at least be mentioned in the CONTRIBUTING.md. I have done so, if this is not desired, please tell me. Has nobody else had this problem before during playing around with the Gui scripts ?
taipy/gui/gui.py
Outdated
# TODO: Add support for directory creation of nested structures | ||
if path: | ||
upload_path = Path(os.path.join( self._get_config("upload_folder", tempfile.gettempdir()), os.path.dirname(path))).resolve() | ||
os.makedirs( upload_path, exist_ok=True ) |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
user-provided value
taipy/gui/gui.py
Outdated
upload_path = Path(os.path.join( self._get_config("upload_folder", | ||
tempfile.gettempdir()), | ||
os.path.dirname(path))).resolve() |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
user-provided value
… of React's attribute naming; Adjusted tests for addition of other attributes.
…upload_files (addresses linter C901) .
#2189
Implementation:
webkitdirectory
in the<include ...>
block, which delivers the directory structure, relative to the point of entry as thewebkitRelativePath
attribute of ablob / file
.blob
and added thefilePath
variable, containing the mentioned relative path, to theFormData
of the request/tmp
by default)Limitations:
webkitdirectory
as an option forInputHTMLAttributes
, so it is added as an attribute (see JSX render won't allow webkitdirectory and directory to be used facebook/react#3468 (comment)), which conflicts with the TypeScript ESLint guidelinesHelp needed: