Closed atrauzzi closed 1 year ago
Additionally, I'm noticing that after implementing the workaround, when I get to the point of trying to send my blob across the wire, I end up only sending something like this:
{"_data":{"blobId":"148cc94a-55a8-432d-871e-be32d045eaec","offset":0,"size":44684}}
This is as opposed to the actual bytes themselves. The routines I'm using to send this data work fine on browser and electron clients...
So, this doesn't resolve the issue, but I think I see what's going on here:
XMLHttpRequest
that's used by axios, things breakAssuming this is all correct, the problem here is that the react native project has made some compatibility-breaking alterations to the Blob implementation. Hopefully these can be resolved so that react native can retain the performance benefits of the Blob APIs as well as compatibility with the rest of the JavaScript ecosystem.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Not stale.
There's a secret key -- FileReader
.
fetch
uses the FileReader
to consume the contents of the blob, as to be compliant with fetch
:
https://github.com/github/fetch/blob/37d10362687492868548c4d70c5c12e4a671771e/fetch.js#L181-L186
React Native has a FileReader
implementation, which takes the "JS blob pointer" and resolves it natively
https://github.com/facebook/react-native/blob/b8d6ef372663fe6d467144abfc5d2c9352dc28d6/Libraries/Blob/FileReader.js#L112
The native FileReaderModule
take the "blob pointer" and reads its bytes
, then resolves them down as a string
https://github.com/facebook/react-native/blob/b8d6ef372663fe6d467144abfc5d2c9352dc28d6/ReactAndroid/src/main/java/com/facebook/react/modules/blob/FileReaderModule.java#L39-L41
My hunch is that axios
may not use a FileReader
to extract the blob?
Not sure. But whatever is going on, it's breaking compatibility with standard JS network code.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Leave it open.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Leave it open.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Leave it open.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Not stale.
Over 2 years since this: https://github.com/expo/expo/issues/2402#issuecomment-443726662
Is this still the recommended way?
Odd that this is still a thing in 2021...
Still, I ❤️ React Native.
I do too but they need to up their game.
When is this going to be fixed for god sake?
Over 2 years since this: expo/expo#2402 (comment)
Is this still the recommended way?
For me that solution causes a crash on the second image upload. This one worked better: https://github.com/expo/firebase-storage-upload-example/issues/15#issuecomment-442142654
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.
Environment
React Native Environment Info: System: OS: Windows 10 CPU: (8) x64 Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz Memory: 6.39 GB / 15.94 GB Binaries: Yarn: 1.12.1 - C:\Users\atrauzzi\AppData\Roaming\npm\yarn.CMD npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Description
I've been working on a new react native project which needs to work with files. Given that the most optimal way to work with binary data in JS environments is via the
Blob
APIs, I set out to find my best option for getting binary references to local filesystem data.After a bit of research, I discovered that I should be using the
fetch
API with local file paths. As a side note, it might have been nice to see official documentation about opening files here. Or possibly even a page dedicated to the topic as I'm sure it's fairly nuanced. 😄Unfortunately when I went to open the file using
fetch
, I ended up experiencing this issue.After a bit more research, it appears that this problem is generally confirmed and an in-depth analysis with a workaround has been documented by @sjchmiela here
Possibly Related
This seems like a regression as the standard API surface area and best practice for obtaining
Blobs
for local filesystem data is not working.