2021年1月26日星期二

Create File object without saving

I'm trying to look for a way to create a .txt File object without saving it to disk in Node.js``. In browser I'd do something like

new File(['file_contents'], 'file_name.txt', {type: 'text/plain'})  

The end aim is to create a .txt file object temporarily for my Discord Bot to send as an message attachment.

From the discord.js documentation, I presume I'm supposed to create a Buffer or Stream object representing the file.

https://stackoverflow.com/questions/65913168/create-file-object-without-saving January 27, 2021 at 01:07PM

没有评论:

发表评论