Repository navigation
v2.3.0 - Upload filename for Buffer and stream
✨ Highlights
🏷️ Name your Buffer and stream uploads
FilesAPI.upload() takes a new filename option. A Buffer or stream used to be stored as file, and converters that carry the input name into the result showed it: a PDF from convert.website_to_pdf was titled "file" when the HTML had no <title>, and the result downloaded as file.pdf.
const fileId = await client.files.upload(Buffer.from(html, 'utf-8'), {
filename: 'Invoice 42',
});For a path, filename replaces the file's basename. Non-ASCII names are kept as they are.
🔧 convert() takes a name for streams too
{ stream, filename? } joins { buffer, filename? } as convert() input.
🐛 Fixed
convert({ input: { buffer, filename } }) dropped filename, so the upload was named file even though the type accepted a name.
💡 Good to know
- The result file is named after the full upload name plus the new extension:
Invoice 42.htmlgivesInvoice 42.html.pdf,Invoice 42givesInvoice 42.pdf. - For
convert.website_to_pdf, the page's own<title>takes priority over the upload name for the PDF title.
🧪 Tests
101 tests passing (8 new: Buffer, stream and path names, the file fallback, non-ASCII names, header-safe quoting, and convert() passing the name through).
📦 Install
npm install conversiontools@2.3.0