3

I have base64 image string in my backend and now I want to use https://github.com/nkzawa/socket.io-stream#sscreateblobreadstreamblob-options which uses File or Blob, how can made Blob in Nodejs ?

1
  • What do you want to achieve? Do you want to send the image from the backend to the browser? Commented Feb 20, 2017 at 21:21

1 Answer 1

6

In Node.js you don't have Blobs but Buffers. You can create a buffer from a base64 string like this:

var str = "iAAANS....SUVORK5CYII="; // <-- use real base64 string here
var buf = Buffer.from(str, "base64");

stream.write(buf);
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks Marc for answer , but the link which I've posted the documentations said "Create a new readable stream for Blob and File on browser." , will it work with Buffer ?
What do you want to achieve? Do you want to send the image from the backend to the browser? Maybe you can show some code you are trying to get running?
I must send to socket BlobStrem , from my node server, and in my node server I have base64 image , how can I convert it to BlobStream ?
As far as I can see BlobStream ist just for the browser side (where you have Blobs). On the server side use var stream = ss.createStream(); stream.write(buffer);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.