I am using action-native for an Android application. And use axios as an http library. When I try to send a Blob object via http post, I will get below error:
HTTP Failure in Axios TypeError: One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property? We don't allow it, as this is an edge case that we do not support. This error is a performance optimization and not spec compliant.
Below is the code that I used to add the blob object to the form data:
let data = new FormData() data.append('image', decodeBase64Image(image));
below is the code for decoding a base64 image. And below code works fine in one of my web apps.
export const decodeBase64Image = (dataURI) => { let byteString; if (dataURI === undefined) { return undefined } if (dataURI.split(',')[0].indexOf('base64') >= 0) byteString = atob(dataURI.split(',')[1]); else byteString = unescape(dataURI.split(',')[1]); // separate out the mime component let mimeString = '' if (dataURI.split(',')[0] != undefined && dataURI.split(',')[0].split(':')[1] != undefined) { mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0] } // write the bytes of the string to a typed array let ia = new Uint8Array(byteString.length); for (let i = 0; i < byteString.length; i++) { ia[i] = byteString.charCodeAt(i); } return new Blob([ia], {type: mimeString}); }
source share