Store Files on Server (streamlit) and access them while air-time of App

@chris_klose thanks for the kind reply, yes it is possible to upload and extract files from cloud locations.

I created a post for retrieving csv data from google cloud link here: https://discuss.streamlit.io/t/google-drive-csv-file-link-to-pandas-dataframe/8057?u=cervone23

You can also upload media files to GCP by creating a google cloud bucket and access the file through a simple url link. The link can easily be converted to a download button for users to download on the front end of a streamlit app - I can provide more code for that if needed!

# upload file to GCP
bucket_name= 'bucket_name'
blob_name = 'blob name'
path_to_file = 'file'


def upload_to_bucket(blob_name, path_to_file, bucket_name):
""" Upload data to a google cloud bucket and get public URL"""
# Explicitly use service account credentials by specifying the private key
# file.
storage_client = storage.Client.from_service_account_json(
    'XXXXXX_gcloud.json'
)
# print(buckets = list(storage_client.list_buckets())
bucket = storage_client.get_bucket(bucket_name)
blob = bucket.blob(blob_name)
blob.upload_from_filename(path_to_file)
# returns a public url
blob.make_public()
return blob.public_url

Hope this helps! @Charly_Wargnier @chris_klose

1 Like