只用Sails Js阅读上传的文件

我想上传一个文件作为一个缓冲区与utf-8编码parsingstring减去该string的一部分,这就是它。

我不想将它保存在磁盘上,因为它现在与船长一起航行。

https://github.com/balderdashy/skipper

我相信你可以通过上传到临时文件,然后从那里读取。 例如

// Since we don't provide any other 'opts' arguments to the upload // method, it will upload our file to a temp directory skipperFile.upload(function (err, uploadedFiles) { // If no files were uploaded, respond with an error. if (uploadedFiles.length === 0) { return res.badRequest('No file was uploaded'); } // Now that the file is uploaded, get the file descriptor var fd = uploadedFiles[0].fd; fs.readFile(fd, 'utf8', function (err, data) { // Print the contents of the file as a string here // and do whatever other string processing you want console.log(data); }); });