Skip to content

file_uploader: support for multiple files#1183

Merged
tconkling merged 15 commits intostreamlit:developfrom
tconkling:tim/MultiFileUploader
Mar 10, 2020
Merged

file_uploader: support for multiple files#1183
tconkling merged 15 commits intostreamlit:developfrom
tconkling:tim/MultiFileUploader

Conversation

@tconkling
Copy link
Copy Markdown
Contributor

This adds basic support for uploading multiple files to a single st.file_uploader

  • st.file_uploader now has a new flag, accept_multiple_files. It defaults to false.
  • When accept_multiple_files is true, the frontend widget will accept multiple files, and the Python API will return a list of BytesIO/StringIO objects if 1 or more files are uploaded to the widget. (That is, even if the user uploads a single file, the multi-file uploader will always return a list. The single-file variant will never return a list.)
  • UploadedFileManager now stores lists of files by session_id/widget_id key, instead of just single files.
  • The e2e test validates the entire round trip of both single and multiple file uploads.

Closes #912 (there are additional API changes to make to file_uploader, but we're going to be addressing them in future PRs.)

@tconkling tconkling requested a review from a team as a code owner March 4, 2020 23:32
* develop:
  Unpin python-dateutil package version (streamlit#1153)
  Pypi nightly builds (streamlit#1171)
  Adding custom filterOptions function to SelectBox (streamlit#1182)
  Expire media files when ReportSession expires (streamlit#1128)
  1159/use_container_width (streamlit#1174)
@monchier
Copy link
Copy Markdown
Contributor

monchier commented Mar 9, 2020

Quick question, if accept_multiple_files is False, the widget does not return a list, right?

@tconkling
Copy link
Copy Markdown
Contributor Author

Correct - this is to preserve the existing API. There's an issue to deprecate the current API, and always return a list - but this PR doesn't implement any of that.

Copy link
Copy Markdown
Contributor

@monchier monchier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly sanity checks kind of comments and minor notes.

More high level: I thought we said at some point to standardize on snake case for python file names... Should we bring it up again?

BytesIO or StringIO or or list of BytesIO/StringIO or None
If no file has been uploaded, returns None. Otherwise, returns
the data for the uploaded file(s):
- If the file is in a well-known textual format (or if the encoding
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is well-known?

* develop:
  Speed up `make jstest` on CircleCI
  De-flake ScriptRunner_test.py (streamlit#1195)
@tconkling
Copy link
Copy Markdown
Contributor Author

More high level: I thought we said at some point to standardize on snake case for python file names... Should we bring it up again?

For posterity: we chatted about this in the standup yesterday, and it sounds like we haven't established a naming rule for python files.

@monchier
Copy link
Copy Markdown
Contributor

Looks good @tconkling .

* develop:
  Another attempt at test_multiple_scriptrunners timeouts (streamlit#1211)
@tconkling tconkling merged commit 76d9ed5 into streamlit:develop Mar 10, 2020
@tconkling tconkling deleted the tim/MultiFileUploader branch March 10, 2020 22:45
tconkling added a commit to tconkling/streamlit that referenced this pull request Mar 10, 2020
* develop:
  file_uploader: support for multiple files (streamlit#1183)
  Another attempt at test_multiple_scriptrunners timeouts (streamlit#1211)
tconkling added a commit to tconkling/streamlit that referenced this pull request Mar 11, 2020
* develop:
  Better error messages for st.cache (streamlit#1146)
  Fix st.cache (streamlit#1208)
  file_uploader: support for multiple files (streamlit#1183)
  Another attempt at test_multiple_scriptrunners timeouts (streamlit#1211)
  Speed up `make jstest` on CircleCI
  De-flake ScriptRunner_test.py (streamlit#1195)
@Lee4396
Copy link
Copy Markdown

Lee4396 commented Jun 16, 2020

it would be great if we can upload folders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can file_uploader upload multi files at one time?

3 participants