streamlit icon indicating copy to clipboard operation
streamlit copied to clipboard

Let file_uploader return path, instead of reading the file in

Open eliska-chalupova opened this issue 6 years ago โ€ข 89 comments

Thanks for implementing the file_uploader widget, I was really looking forward for that.

Problem

My issue is that I expect large files (up to GBs), and thus reading them directly into memory is not acceptable for me.

Solution

separate file_picker One option would be to implement it as a separate widget (e.g. file_picker), which would just help to locate the file without uploading it.

optional upload Other possibility that comes to my mind would be an option (e.g. upload=False), that would allow me to choose not to upload the file. String with absolute path would be returned instead.

Also as mentioned in other issues, even if I could work with the file itself, I'd still need it's path, name, suffix etc. to work with.

URL Maybe in the future, but it would be really nice if the widget could also accept an URL.

Thanks in advance for considering the changes.


Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.

If you'd like the Streamlit team to prioritize this feature request, please use the ๐Ÿ‘ (thumbs up emoji) reaction in response to the initial post.

Views

eliska-chalupova avatar Jan 01 '20 12:01 eliska-chalupova

Hi @eliska-malanikova and happy 2020! ๐ŸŽ†

Are you trying to read a file on the computer running the Streamlit server (where you ran streamlit run) or on the Streamlit client (where the browser is)?

If the former, you can create an ad-hoc file selector like this. Does this help?

treuille avatar Jan 01 '20 16:01 treuille

Hi @treuille, thanks for the quick reply and happy new year to you too.

Currently it's both, server and client, but the aim is to let the user pick files from their own computer (the client), so it would be helpful to let them browse through the folders. So unfortunately, what you proposed does not help me. However, I first let them do some set-up (like define several files), and just after they're finished I read and process the files.

eliska-chalupova avatar Jan 01 '20 19:01 eliska-chalupova

Got it. Thanks @eliska-chalupova . We will take your feedback into account as we plan updates to the file_uploader API. Thanks!

treuille avatar Jan 03 '20 18:01 treuille

Great, thanks @treuille for the consideration. Good luck with the updates.

eliska-chalupova avatar Jan 04 '20 12:01 eliska-chalupova

A functionality which returns the path would be useful for me as well. My use-case is that I want the user to be able to select a folder in which different files are stored, without them having to manually copy-paste the path.

bvandijkman avatar Jan 23 '20 08:01 bvandijkman

I would like to add my support for this request as well. For my use case, the server will be in the same file system. The size of the file is typically big and hence not reasonable to upload. I currently use tk as a workaround. But it would be very nice if the file uploader can support file selctor and also return the path.

jhouma avatar Mar 11 '20 19:03 jhouma

Hi - I too would like to add my support for this request. In particular it'd be nice to get the name of the file added to the file_uploader. I'd also like a way (or would like to know how) to reset the state of the file_uploader so it doesn't take the value of the previously uploaded file when the page is re-evaluated.

I've been using streamlit a lot, and presented it to our Data Science community in Oxford to much excitement. Many thanks for this excellent platform! There are still some weird things to get your head around regarding how the code is diff-executed and it does affect the code structure a little, but apart from that a really awesome tool!

asehmi avatar May 24 '20 15:05 asehmi

+1

My use case is I am writing a tool to retrieve data from files, and it requires a third-party reader to read the files first and that reader requires a file path instead of an IO object. For now, I have to put the file paths in a select box for interactions, but I will have to copy/paste the path into the source code and every time be sure to choose the right one from the drop down list. If the file_uploader could return a file path, it will be more awesome.

cuteufo avatar Jun 23 '20 04:06 cuteufo

+1

As a file is selected, I would like to upload it to GCP, and I need the path to avoid storing it before the upload. As written by @cuteufo, If the file_uploader could return a file path, that would be awesome.

Thanks a lot for the amazing work!

Dataggredate avatar Jul 17 '20 06:07 Dataggredate

Hi anyone can tell how to write code for reading only for file path?

pavanda avatar Sep 28 '20 06:09 pavanda

New file uploader widget is great! But Iยดm still wondering if it is possible to reading in file path? It would be really nice to have something like uploaded_file.fullpath. The reason is I want to create a COM Object and need to pass a string but uploaded_file.name is not working.

ingebert avatar Oct 10 '20 15:10 ingebert

This appears to still be a pressing issue with no clean solution. The suggestion outlined in another post is close but selecting any directory outside of that of the app is difficult to set. My use case would be to run the app locally and to access files larger than 200 MB where having access to the file can minimize a full upload into memory.

bhclowers avatar Oct 12 '20 04:10 bhclowers

Hi @treuille , are there any updates on this feature request?

rembishj avatar Jan 19 '21 18:01 rembishj

Hi @rembishj : For server-side file selection, I would suggest something like this snippet.

treuille avatar Jan 20 '21 04:01 treuille

Hi once again @treuille, is anybody working on this feature?

I would like to be able to save full path of a filename uploaded by user (with st.file_uploader), .name is not enough for me ๐Ÿ˜ฅ

mtszkw avatar May 18 '21 13:05 mtszkw

Hi @mtszkw and others: I'm a PM at Streamlit and wanted to share that this feature is on our roadmap. We're working on higher priority stuff right now, so currently it's not being actively developed. The earliest we will be able to get to it is probably end of Q3, 21. Thanks, and stay tuned!

asaini avatar May 18 '21 22:05 asaini

Hi thank you I will wait for it is going to be really useful

yemre-data avatar Jun 19 '21 14:06 yemre-data

Hi thank you I will wait for it is going to be really useful

locpv98 avatar Jun 25 '21 03:06 locpv98

+1

XDynames avatar Oct 11 '21 04:10 XDynames

waiting for this feature to get the file path.

someone with a temporary solution for now?

pranav7712 avatar Oct 21 '21 03:10 pranav7712

Any update on this?

giladrefael avatar Mar 05 '22 14:03 giladrefael

+1 for this feature.

hazeez avatar Mar 17 '22 03:03 hazeez

+1

Alernst avatar Mar 23 '22 08:03 Alernst

+1

wenig avatar Mar 23 '22 15:03 wenig

any update/ETA on this ?

devrimcavusoglu avatar Apr 22 '22 08:04 devrimcavusoglu

Any update on this?

yharby avatar Jun 15 '22 13:06 yharby

cc: @jrieke

asaini avatar Jun 15 '22 14:06 asaini

+1

blacksheepyy avatar Jun 22 '22 08:06 blacksheepyy

+1

jscanass avatar Jul 01 '22 20:07 jscanass

+1

nelsonroque avatar Jul 09 '22 17:07 nelsonroque