Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
1.1 KiB
Plaintext
1 line
1.1 KiB
Plaintext
{"version":3,"sources":["../../src/uploads/saveBufferToFile.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport { Readable } from 'stream'\n\n/**\n * Save buffer data to a file.\n * @param {Buffer} buffer - buffer to save to a file.\n * @param {string} filePath - path to a file.\n */\nexport const saveBufferToFile = async (buffer: Buffer, filePath: string): Promise<void> => {\n // Setup readable stream from buffer.\n let streamData = buffer\n const readStream = new Readable()\n readStream._read = () => {\n readStream.push(streamData)\n streamData = null!\n }\n // Setup file system writable stream.\n return await fs.writeFile(filePath, buffer)\n}\n"],"names":["fs","Readable","saveBufferToFile","buffer","filePath","streamData","readStream","_read","push","writeFile"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,SAASC,QAAQ,QAAQ,SAAQ;AAEjC;;;;CAIC,GACD,OAAO,MAAMC,mBAAmB,OAAOC,QAAgBC;IACrD,qCAAqC;IACrC,IAAIC,aAAaF;IACjB,MAAMG,aAAa,IAAIL;IACvBK,WAAWC,KAAK,GAAG;QACjBD,WAAWE,IAAI,CAACH;QAChBA,aAAa;IACf;IACA,qCAAqC;IACrC,OAAO,MAAML,GAAGS,SAAS,CAACL,UAAUD;AACtC,EAAC"} |