St.file_uploader - AxiosError: Request failed with status code 403

:rotating_light: Before clicking “Create Topic”, please make sure your post includes the following information (otherwise, the post will be locked). :rotating_light:

  1. Are you running your app locally or is it deployed? Currently, locally
  2. If your app is deployed:
    a. Is it deployed on Community Cloud or another hosting platform? Community Cloud
    b. Share the link to the public deployed app. Not currently deployed publicly since it is a University coursework, can give access if needed
  3. Share the link to your app’s public GitHub repository (including a requirements file). Again, private as it is a University submission, can give access if requested.
    Can send over the requirements.txt
  4. Share the full text of the error message (not a screenshot). AxiosError: Request failed with status code 403
  5. Share the Streamlit and Python versions. Streamlit 1.28.2
    Python version 3.11.3
1 Like

Hi @cr2007

It would be helpful for the community if a reproducible code snippet is shared so that the issue faced can be reproduced.

Can you try specifying the latest version of Streamlit in requirements.txt:

streamlit==1.28.2

Also, what file type are you uploading with st.file_uploader?

1 Like

Hi @dataprofessor ,

Update on the matter, st,file_uploader() works fine now. The issue was that I was running it in the Simple Browser feature on VS Code
Instead of the normal web browser.

So it is working as intended.

To answer your questions earlier, I am using Streamlit 1.28.2 as mentioned in the above post.

I was trying to upload a JSON data set file, and I am trying to find a way to read the lines and store it in a list.
If there is a way I can use it with the JSON Python library, please do let me know, or kindly direct me to a similar post on the same.

1 Like

Hi,

I have an app using streamlit and st.file_uploader that is hosted on Azure web services. The uploader keeps on failing every then and now giving the following error:

AxiosError: Request failed with status code 400

Any idea how to solve the problem?

Here is the associated code:

file_1 = st.sidebar.file_uploader(
label=‘:violet[Select PDF, word, or text files to upload]’,
type=[‘pdf’, ‘docx’, ‘txt’],
accept_multiple_files=False, key=‘file_1’,
label_visibility=‘hidden’)

if file_1:
st.session_state.file_to_upload_1 = convert_file_to_text(file_1)

The config.toml file has the following:

[server]
maxUploadSize = 100
enableXsrfProtection = false
enableCORS = false

Thanks,
Samuel

1 Like

Hi @cr2007

Yes, you can upload and read in the JSON file.

Reading in a JSON file can be done using the json library:

import json

read_json_file = json.load(uploaded_file)
1 Like

st.file_uploader(type=[“zip, pdf”]) returns “AxiosError: Request failed with status code 403” when streamlit app is deployed on Heroku.
The error appears starting with streamlit version==1.30.0.
The app works fine on heroku with streamlit==1.29.0

3 Likes

Same problem here

file_uploader works at localhost but not at deploy domain.

streamlit 1.32.0

Same here
file_uploader shows AxiosError: Request failed with status code 403 within deployed domain
streamlit version 1.32.0

Love the new function, 1.31(write_stream) and 1.32(popover), but due to file_uploader in ongoing project, i have to downgrade to 1.29, has anyone have any workarround with this problem?