I looked at a lot of options online to convert ArrayBuffer to buffer and tried them but it doesnt seem to work and throws the
error : Could not conver to bufferTypeError: Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information."
Code
export function convertToBuffer ( arrayBuffer ) {
console . log ( "Array buffer " + arrayBuffer );
var newBuffer = Buffer . alloc ( arrayBuffer . byteLength );
for ( var i = 0 ; i < arrayBuffer . length ; i ++) {
newBuffer [ i ] = arrayBuffer [ i ];
}
console . log ( "New buffer " + newBuffer );
return newBuffer ;
}
export function convertToUint8Buffer ( arrayBuffer ) {
console . log ( "Array buffer " + arrayBuffer );
const buffer = Buffer . alloc ( arrayBuffer . byteLength );
const view = new Uint8Array ( arrayBuffer );
for ( let i = 0 ; i < buffer . length ; ++ i ) {
buffer [ i ] = view [ i ];
}
console . log ( "Uint8 Array " + buffer );
return buffer ;
}
Non of these two seem to work. I have requested wix to approve for npm package arrayBuffer-to-buffer but not sure how much time it will take so looking for alternate solutions. Any help would be great