Skip to content

buffer.write(buffer, 'base64') #11866

Description

@jorangreef

What's the fastest way to convert a buffer containing base64-encoded data to a buffer containing binary data?

Something like this?

var base64Buffer = ...; // e.g. A buffer containing base64 provided by a mime decoder.
var binaryBuffer = new Buffer(base64Buffer.toString('ascii'), 'base64')

Is there a way to write the base64 buffer directly into another buffer, without creating any interim strings?

I thought of binaryBuffer.write(base64Buffer, 'base64') but write() only accepts strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions