Download issues!
Hello,I’m trying to deploy a model using streamlit and I am having some troubles downloading my result. I’m using the download button from streamlit (st.download_button - Streamlit Docs), but every time I get the same error: “404 Sorry, we can’t find the page you are looking for”. Is there anyone that has faced the same issue with streamlit that can give me some advice? Or is there another way to download something on hugging face?Thank you.
2023-06-23T20:29:33Z
I currently have the same issue and could not resolve it.
2023-06-29T09:31:40Z
I created my own link to download files from huggingface since the streamlit button is not working. Have a look over at this space, which also shows the problem with the link:Streamlit Download Experiment - a Hugging Face Space by cansikBut this only works for file sizes that do not exceed the url-charachter limit!Btw. even downgrading does not work. I tried to stick to an old version of streamlit (likesdk_version: 1.21.0) and adding thealtair==4.1.0requirement (as mentionedhere).
2023-06-30T00:31:47Z
cc@whitphxcurrently maintaining Streamlit Spaces SDK
2023-06-30T07:27:28Z
Thank you so much for the report!Will investigate it with the infra team. Let us take a bit more.
2023-06-30T10:16:21Z
@cansikAlthough we haven’t found the root cause yet, let me suggest one possible workaround:I found thatyour Spaceis now configured to use Streamlit1.12.2, not1.21.0, and it may be solved by upgrading the Streamlit version to1.21.0for example, as I experimented inthis Spacewhich I duplicated yours.
2023-06-30T11:00:29Z
@whitphxYes I am aware of that, it was a test to see if it works with an older version, but the problem is that it does only work for smaller files, not large files (like 10mb). If you want I can create an example that shows the exact problem.
2023-06-30T12:55:07Z
Ah, OK, you mentioned the problem ofst.download_button()which occurs particularly with large files.I encountered a different bug of the older version and misunderstood it.Will take a look into it again.
2023-06-30T14:37:46Z
I think found the problem: if the space is private, downloads do not work leading to 404 error, if the space is public it seems to work.
2023-06-30T15:38:07Z
@cansikThank you, that’s an important info! Can you share the code?I was also trying to reproduce the error in my private Space, but couldn’t…Can you try the code below when you have time, to check if the error occurs in your env or to specify the problem? Thank you.README.md---
title: Streamlit Private Download Experiment
emoji: 🌖
colorFrom: red
colorTo: red
sdk: streamlit
sdk_version: 1.21.0
app_file: app.py
pinned: false
license: mit
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-referenceapp.pyimport random
import string
import streamlit as st

text_contents = '''This is some text'''
st.download_button('Download a small text file', text_contents)


@st.cache_data
def create_large_data():
    data = ''.join(random.choices(string.ascii_uppercase, k=1024 * 1024 * 10))
    data = bytes(data, "utf-8")
    return data

large_data = create_large_data()
st.download_button('Download a large file', large_data)
2023-06-30T15:52:56Z
I just noticed that I am using the Brave browser which disables cross-site-cookies for security reasons. Could it be that the cookie forhuggingface.cois not valid forcansik-streamlit-download-experiment.hf.spacewhich seems like the address for the media download?By disabling the cookie blocker it works now also on private repositories! Thank you for helping me with this issue. If this is really the issue, maybe there should be an access denied error shown instead of the 404. This would it make more clear (and maybe a message to disable the cookie / ad blocker). Or changing the download url to the original url instead of a subdomain.
2023-07-03T07:26:08Z
@cansikThank you very much, that’s so helpful investigation!I also could confirm the error with Brave.I will let our infra team know this topic and your suggestion, and make some discussions!
2023-07-11T01:52:29Z
My space was also private, but I have decided to move my model for a local server and after that I didn’t try it here again.However, thank you, everyone.