How to store input files on disk?

Hi, I spent hours trying to solve a basic this basic thing. How to store input files on diks?

the below does not work

def save(file):
  
  
  global df #used to access dataframe object  in jupyter notebook while debugging

  s=str(file.file.read(),'utf-8')
  data = StringIO(s)
  df=pd.read_csv(data)
  
  return df

demo = gr.Interface(save, "file", "dataframe")
demo.launch(share=True)

gives pandas.errors.EmptyDataError: No columns to parse from file white tying to upload a valid csv file

Gradio Docs is not helpful for saving files

    def save(files):
        for file in files:
            with open(file.name) as f:
                df = pd.read_csv(StringIO(f.read()))
                df.to_csv(file.orig_name)
1 Like

Hi @dimadgo, is there a way to save the file buffer directly without exclusively reading it?