Not able to download earth engine images

I have deployed a streamlit app and this is my github repo. This app generates a google earth engine image and downloads the images by fetching the url using getDownloadURL function of earth engine and then writing the binary files. the format if the file is Geotiff. I am able to download the images when the app is run locally. I have successfully deployed the app but I am not able to download the images. When I run the app in the cloud and when I press download button, nothing is getting downloaded. I can see the st.success message with the tick icon, but cant able to locate where the file is downloaded. I am pretty new to streamlit as well as google earth engine

Streamlit has a server-client structure. The server is the computer running the Python logic. The client is where the user is viewing the app through a browser. During local development, your server and client are conveniently the same computer. When you deploy your app to Streamlit Community Cloud, any file write commands are happening on the server which is some far-away container.

If you want a client to download a file, check out st.download_button.

Hello, I used the logic present in ee.Image.getDownloadURL  |  Google Earth Engine  |  Google for Developers.

My code looks like this:

Function to export the image to a GeoTIFF file

def export_image(image, date):
# Export the image directly to the deployment environment
url = image.getDownloadURL({
‘name’: f’image{date}',
‘scale’: 20,
‘crs’: ‘EPSG:4674’,
‘region’: roi.geometry().getInfo(),
‘format’: ‘GEO_TIFF’
st.sidebar.success(f"Image exported for {date} successfully. Download here.“)
except Exception as e:
st.sidebar.error(f"Error exporting the image: {str(e)}”)

Button to trigger the data download

if st.sidebar.button(“Download Data”):
# Check if the ROI is defined
if ‘roi’ in locals() and roi is not None:
# Export the selected collection to GeoTIFF files
for date in selected_dates:
# Filter the collection for the selected date
selected_collection_date = selected_collection.filter(ee.Filter.eq(‘data’, date))
# Export the first image in the filtered collection
export_image(selected_collection_date.first(), date)
st.warning(“Please select an area of interest before downloading.”)