Buffer
(logo.png)
The following code reads Logo.png as the buffer type
Then convert the buffer to a string
You can configure a string:data:image/png;Base64,Buffer.toString()
varFs= require(' FS ')FS.ReadFile(' Logo.png ',function(Err,Origin_buffer){ Console.Log(' origin_buffer If buffer format: '+Buffer.Isbuffer(Origin_buffer))//console.log (' Read to Origin_buffer: ' + origin_buffer) //Create file FS.WriteFile(' Log_buffer.png ',Origin_buffer,function(ERR){ if(ERR)Console.Log(ERR)})//var base84image = new Buffer (origin_buffer). toString (' base64 ') //Convert to String varBase64image= Origin_buffer.toString(' base64 ')Console.Log(' string base64image: ' +Base64image)varDecodedImage= New Buffer(Base64image, ' base64 ')//console.log (' encoded decodedimage: ' +decodedimage) //console.log (' Compare origin_buffer and DecodedImage: ' + buffer.compare (origin_buffer,decodedimage)) FS.WriteFile(' Logo_decoded.png ',DecodedImage,function(ERR){ if(ERR)Console.Log(ERR)})})
11 MU class Network "Attack on node. JS Foundation (i)" Buffer and stream