Skip to main content

Managing file with buffer

With a Buffer, you can store files directly inside the Spell's memory.

Here is a snippet to store a remote file inside a Buffer:

const imageInBuffer: Buffer = await axios.get(
responseType: "arraybuffer",

You can also create a Buffer from a string (utf8) or an object:

const fileInBuffer = new Buffer.from(myObject);

Or a base64 string:

const fileFromBase64 = new Buffer(base64String, "base64");

Then you can manipulate this variable to output a file or to link it inside a POST request, etc.


Memory are limited inside a Spell. If you tried to store too large files inside a Buffer, you'll break your Spell's execution.

By default, memory inside a Spell is limited to 128MB