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 ?

mscdex
107k15 gold badges201 silver badges159 bronze badges
asked Feb 20, 2017 at 20:29
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);
answered Feb 20, 2017 at 21:28

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);

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.