Hi,
in my code I was fetching an Image and converting it to base64.
Basically I am using this piece of code:
const reader = new FileReader()
reader.readAsDataURL(response)
reader.onloadend = function() {
const base64data = reader.result
console.log('--', base64data)
resolve(base64data)
}
This conversion was working perfectly before migrating Expo 31, now the result is always something like
-- data:application/octet-stream;base64,77+9UE5HDQoaCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... (thousands of As)
Do someone know what could be happening?
Thanks!
Hey @ivan-travelperk ,
I haven’t seen any other reports of this. Is this occurring on both platforms? If it’s just happening on Android, it may be related to the recent JSC upgrade that was part of the SDK31 release.
Cheers,
Adam
for the moment I’ve found it in Android, specifically the error is in react-native/Libraries/Blob/FileReader readAsDataURL
then it seems more related to react-native than Expo.
I also found an open issue for react-native
opened 02:22PM - 13 Sep 18 UTC
closed 12:05AM - 28 Sep 18 UTC
Ran Commands
Resolution: Locked
- [x] Review the documentation: https://facebook.github.io/react-native
- [x]… Search for existing issues: https://github.com/facebook/react-native/issues
- [x] Use the latest React Native release: https://github.com/facebook/react-native/releases
## Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 593.19 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.3 - /usr/local/bin/node
Yarn: 1.0.2 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
Android SDK:
Build Tools: 21.1.2, 23.0.1, 23.0.2, 23.0.3, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.2, 27.0.3, 28.0.0
API Levels: 22, 23, 24, 25, 26, 27, 28
IDEs:
Android Studio: 3.0 AI-171.4443003
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
@storybook/react-native: ^3.4.8 => 3.4.10
@types/react: ^16.4.1 => 16.4.12
react: 16.3.1 => 16.3.1
react-native: ^0.57.0 => 0.57.0
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-rename: 2.2.2
## Description
I need to parse an image that receive from a fetch request into an base64 string. When I as using RN 0.55.4 my code worked properly, but after upgrading to RN0.57 (and RN0.56) it didn't worked anymore.
I've logged my base64 string after upgrade, and I get:
`IMAGE64 data:application/octet-stream;base64,77+977+977+977+9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...(a bunch of "A"s)`
in RN0.55.4, my base64 string was totally different.
## Reproducible Demo
That's how I do the request and parsing:
```javascript
const reader = new FileReader();
fetch(`${ENDPOINT}/tudo/v2/services/person/profileimage`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
},
}).then((res) => res.blob())
.then((blob) => {
reader.readAsDataURL(blob);
reader.onloadend = function () {
const base64data = reader.result;
if (base64data.length > 500) {
AsyncStorage.setItem(`@Profile:imageBase64-${document}`, base64data);
callback(base64data);
}
};
}).catch((err) => { /* onsole.log('IMAGE ERROR', err, arguments); */ });
```
Ah, I clearly didn’t do a thorough enough search of RN’s issues. I would follow along at the issue you linked since as you stated it’s more in the realm of RN than Expo. Hope it gets resolved soon!
system
Closed
January 2, 2019, 6:07pm
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.