I am using async-busboy to read a .txt file uploaded from multipart form in postman. However, it can't read the file content so the buffer in the returned "files" object is always empty, and the length of the file is zero.
I believe this method creates a tmp file, rather than a readable stream.
"path": "/tmp/0d812ea775d47-test1.txt"
Is there a file at that location?
cat /tmp/0d812ea775d47-test1.txt
I am using async-busboy to read a .txt file uploaded from multipart form in postman. However, it can't read the file content so the buffer in the returned "files" object is always empty, and the length of the file is zero.
My code: router.post( '/attachment',async (ctx, next) => { try { const {files, fields} = await asyncBusboy(ctx.req); ctx.code = 200; ctx.body = { code: 200, data: files, }; } catch (err) { log.error(err); ctx.throw(500, 'Internal Server Error'); } }, );
The returned file object: [ { "_readableState": { "objectMode": false, "highWaterMark": 65536, "buffer": { "head": null, "tail": null, "length": 0 }, "length": 0, "pipes": null, "pipesCount": 0, "flowing": null, "ended": false, "endEmitted": false, "reading": false, "sync": true, "needReadable": false, "emittedReadable": false, "readableListening": false, "resumeScheduled": false, "destroyed": false, "defaultEncoding": "utf8", "awaitDrain": 0, "readingMore": false, "decoder": null, "encoding": null }, "readable": true, "domain": null, "_events": {}, "_eventsCount": 1, "path": "/tmp/0d812ea775d47-test1.txt", "fd": null, "flags": "r", "mode": 438, "start": 0, "end": null, "autoClose": true, "pos": 0, "bytesRead": 0, "fieldname": "", "filename": "test1.txt", "encoding": "7bit", "transferEncoding": "7bit", "mime": "text/plain", "mimeType": "text/plain" } ] }