How to access filename from FileInput & how to save the file also

Hello, I am trying to upload some .wav files by using FileInput widget, after get the files I wish to get the name/and change the filename, then save/ download the documents.

for now:

  1. I can’t get the name of the file
  2. I didn’t find a way to save the file

Here is my short example:

#this is a simplified code from what I am trying to do
from bokeh.models import FileInput

#a list to store original file name
list1 = []
#a list to store changed file name
list2 = []

#here: allow only wav files
file_input1 = FileInput(accept=".wav") 

#to get the name of the file
def upload_data1(attr, old, new):
    #get the name of the file
    list1.append(file_input1.filename) #I tried but can't get the name
    print(list1)

file_input1.on_change('value',upload_data1)

thank you very much.

individual property events fire separately, which means they fire in an order. I think the value property change is triggered before the filename property change. In that case, you could trigger your callback off filename instead of value

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.