-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Fetch image from android phone returning Failed to construct 'Response': The status provided (0) is outside the range [200, 599]. #38625
Comments
|
@Punit-Vajpeyi - Fetch won't work against filesystem files. Thus you get a
So that error looks intended and thus not a bug. |
But it was working for working for last 2 months the same code. I was
uploading files to the server using following code snippet.
const response = await fetch(imagePath);
const imageData = await response.blob();
await fetch(url, {
body: imageData,
method: ‘PUT’
});
Can you suggest what to do?
…On Wed, 26 Jul 2023 at 3:06 AM, Connor Tumbleson ***@***.***> wrote:
@Punit-Vajpeyi <https://github.com/Punit-Vajpeyi> - Fetch won't work
against filesystem files. Thus you get a 0 because you didn't get an HTTP
response back and thus failed.
The Fetch API <https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API>
provides a JavaScript interface for accessing and manipulating parts of the
protocol <https://developer.mozilla.org/en-US/docs/Glossary/Protocol>,
such as requests and responses. It also provides a global fetch()
<https://developer.mozilla.org/en-US/docs/Web/API/fetch> method that
provides an easy, logical way to fetch resources asynchronously across the
network.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
So that error looks intended and thus not a bug.
—
Reply to this email directly, view it on GitHub
<#38625 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADDQWB6TPPWXWV2NR46TOJ3XSA36NANCNFSM6AAAAAA2XO45TM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Sorry @Punit-Vajpeyi I shouldn't have responded. I'm either completely wrong and somehow fetch() supports You mention things worked for last 2 months, but RN72 hasn't been out that long. That code above appears to be working with HTTP as you aren't sending PUT method calls to a filesystem. So I'm sorry - nothing posted here makes sense to me and I shouldn't have responded. Best of luck. |
The above snippet worked on RN71 then I upgraded to RN72 and it started to
return the error status.
RN71 used to support file://.
I will check the change log for this, seems like the version issue, will
also try to downgrade once again to RN71.
…On Wed, 26 Jul 2023 at 6:06 AM, Connor Tumbleson ***@***.***> wrote:
Sorry @Punit-Vajpeyi <https://github.com/Punit-Vajpeyi> I shouldn't have
responded. I'm either completely wrong and somehow fetch() supports
file:// properties in RN or I am still right and you aren't providing
context and doing something that frankly makes no sense.
You mention things worked for last 2 months, but RN72 hasn't been out that
long. That code above appears to be working with HTTP as you aren't sending
PUT method calls to a filesystem.
So I'm sorry - nothing posted here makes sense to me and I shouldn't have
responded. Best of luck.
—
Reply to this email directly, view it on GitHub
<#38625 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADDQWB5G53W4QARUOXYHN5DXSBQ7JANCNFSM6AAAAAA2XO45TM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@Punit-Vajpeyi I was facing the same issue. This StackOverflow solution helped me. https://stackoverflow.com/questions/55957683/get-picked-image-on-android-with-react-native-fetch-api I hope it helps you too. |
We faced the same issue using RN 0.71 and the root cause was related to an unintended upgrade of The suggestion by @MGuerra17 unfortunately didn't work for us. |
@AlexanderEggers how to use const getBlob = useCallback(fileUri => { |
I was trying to figure this out for 2 hours, thank god i'm not the only one. This was working perfectly fine on 0.71 and it's broken on 0.72.x |
same issue |
Just use this as as workaround for now: https://stackoverflow.com/a/76761937/503059
Usage |
Per this issue, it's as expected to throw an error on But should fetch API support According to fetch spec - Schema fetch:
I'm not sure what's the exact meaning of the spec. Any native speaker or spec expert could help answer it? 🤔 Anyway, regardless the fetch spec and the updates of whatwg-fetch package, using the snippet in the previous comment should always be a safe solution. |
@Punit-Vajpeyi Should be able to be closed, fixed in this pr JakeChampion/fetch#1375 |
@stefan-schweiger tyy ! Its worked for me. But i maked the mistake don't use |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Description
While trying to read image from android phone internal storage, I am getting Failed to construct 'Response': The status provided (0) is outside the range [200, 599].
fetch(imagePath)
sample url: file:///data/user/0/com.test_app/cache/rn_image_picker_lib_temp_5c90be23-f414-4a9f-978a-cae5239fdd25.jpg
React Native Version
0.72.3
Output of
npx react-native info
System:
OS: macOS 13.4.1
CPU: (8) arm64 Apple M2
Memory: 126.95 MB / 8.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.3.0
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.19
path: /opt/homebrew/bin/yarn
npm:
version: 9.6.7
path: /opt/homebrew/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.12.1
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 22.4
- iOS 16.4
- macOS 13.3
- tvOS 16.4
- watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.9971841
Xcode:
version: 14.3/14E222b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.19
path: /opt/homebrew/opt/openjdk@11/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.3
wanted: 0.72.3
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Steps to reproduce
Snack, screenshot, or link to a repository
The text was updated successfully, but these errors were encountered: