Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File fetching broken since commit 0c1d2b9 #1371

Closed
ldaudet opened this issue Aug 2, 2023 · 3 comments
Closed

File fetching broken since commit 0c1d2b9 #1371

ldaudet opened this issue Aug 2, 2023 · 3 comments

Comments

@ldaudet
Copy link

ldaudet commented Aug 2, 2023

Hi there!

Thanks a lot for the work on this library! I am using it in a react native app to run code like this: https://snack.expo.dev/@bacon/documentpicker-to-blob (line 24), to grab an image file that I will then upload to the backend.

This worked for the longest time, but after uploading to the latest version of expo, it also uploaded the version of react native, which in turned updated our version of fetch. The problem is that with the latest version of fetch, the fetch of file doesn't work anymore, as described here: facebook/react-native#38625 (comment)

After looking at the code, I realized that the issue was actually do to the work on commit 0c1d2b9 where you added a check for the return code to be between certain values:

  if (this.status < 200 || this.status > 599) {
    throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
  }

When removing this check, everything works just fine with fetching the file, even with the lastest version of fetch, as the fetch of the a file return a status 0.

Would it be possible to either remove the check, or update the code to get a 200 status on successfully fetching a file?

Thanks a lot

@mercpls
Copy link

mercpls commented Aug 24, 2023

@ldaudet Still waiting on a response but there is a PR based on this suggestion now.

@meteorlxy
Copy link

meteorlxy commented Aug 28, 2023

According to fetch spec - Schema fetch:

"file"
For now, unfortunate as it is, file: URLs are left as an exercise for the reader.

When in doubt, return a network error.

I'm not sure what's the exact meaning of the spec - Should fetch support file uri or not?

Any native speaker or spec expert could help answer it? 🤔

@JakeChampion
Copy link
Owner

Fixed via #1375 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants