Open rpostulart opened 1 year ago
Related #11588
HI @rpostulart thank you for opening this issue. Looks like you are having issues with Predictions where an error Buffer is not found. This is currently being tracked on the above linked issue, however I may have a work around that can work for you which depends on a 3rd party dependency.
Could you take a look at this comment and let me know if this work around unblocks you? The difference I see between this example and what you are doing is it takes use of the base64 photo instead of the photo uri.
No, i get: [ReferenceError: Property 'Buffer' doesn't exist]
This is the code:
import { toByteArray } from "react-native-quick-base64";
const options = { quality: 0.7, base64: true };
const photo = await cameraRef.current.takePictureAsync(options);
const bytes = toByteArray(photo.base64);
try {
await Predictions.identify({
text: {
source: { bytes },
},
});
} catch (error) {
console.log("AAA", error);
}
Same issue for me
I found a workaround if it can help, you will need to install base-64
then use it as follow :
import { decode as atob } from "base-64";
...
const base64ToArrayBuffer = (base64) => {
const binaryString = atob(base64);
const length = binaryString.length;
const bytes = new Uint8Array(length);
for (let i = 0; i < length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes.buffer;
};
...
const { entities } = await Predictions.identify({
entities: {
source: {
bytes: base64ToArrayBuffer(imageResult.base64),
},
},
});
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Predictions
Amplify Categories
predictions
Environment information
Describe the bug
i get: ReferenceError: Property 'Buffer' doesn't exist
i get: Error: FileReader.readAsArrayBuffer is not implemented
Expected behavior
I expect the detectText endpoint will give a response
Reproduction steps
Use Expo with AWS Amplify
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response