Uploading file from vm

Hello Everyone,
The app that I wrote plays audio by allowing the user to upload their audio file using the st.file_uploader function. Everything works well on my local machine, but now I need to place this app on a remote virtual Linux machine where the user would select the audio file found in the vm’s directory.
I can access the app using the URL, but I can only still select files on my local machine. How can I access or view the files on the vm like in the case when my app is running on my local machine? Any ideas? I appreciate your feedback!

Hi @luckylouman, you probably won’t be able to make a file_upload button which uses files from the linux machine, as that browser’s file_upload dialogue always selects from your machine. But, you can do something like this to use a selectbox instead to pick from the files in a folder

from pathlib import Path

import streamlit as st

files = [file for file in Path("media/").glob("*.mp3")]

file = st.selectbox("Select a file", files)

Thank you blackary! I will try that method.

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