Gistlib Logo

gistlib

blob to buffer in javascript

index.tsx
const blob = new Blob(["Hello, World"], { type: 'text/plain' });

const fileReader = new FileReader();
fileReader.onload = function(event) {
    const buffer = event.target.result;
    console.log(buffer); // This will be the buffer representation of the blob
};

fileReader.readAsArrayBuffer(blob);
300 chars
10 lines

similar javascript code snippets

how to use the buffer function from the rxjs library in javascript
how to use the isbuffer function from lodash in javascript
how get image md5 hash from image buffer in the browser in javascript
convert base64 to blob and store it in a variable in javascript
send a binary message to a tcp server in javascript
how get image md5 hash in the browser from image buffer in javascript
md5 file checksum from image buffer in javascript
how get image md5 hash from base64 image buffer in the browser in javascript
send a binary message to a udp server in javascript
base64 decide in javascript

related categories

javascript
buffer
blob

gistlibby LogSnag