如何处理NodeJS中的file upload?

我有这个代码:

http.createServer(function (req, res) { if (req.method.toLowerCase() === "post") { res.writeHead(200); req.on('data', function (data) { console.log(data.toString()); }); res.end(); } }).listen(8006); 

如果我尝试使用curl命令(如curl http://localhost:8006/upload -X POST -F file=@filetoupload.txt ,我将获取文件的名称和文件的内容打印出来,在这种情况下是这样的:

 ------------------------------5d02ba973600 Content-Disposition: form-data; name="file"; filename="filetoupload.txt" Content-Type: text/plain <!-- start slipsum code --> Do you see any Teletubbies in here? Do you see a slender plastic tag clipped to my shirt with my name printed on it? Do you see a little Asian child with a blank expression on his face sitting outside on a mechanical helicopter that shakes when you put quarters in it? No? Well, that's what you see at a toy store. And you must think you're in a toy store, because you're here shopping for an infant named Jeb. <!-- end slipsum code --> ------------------------------5d02ba973600-- 

现在的问题是,有没有什么好的方法来获取文件名的值和文件的内容? 或者我将不得不进入某种正规expression式巫术来提取上述内容的价值?

我想这样做没有任何第三方模块像快递,首先,因为我想了解这是如何工作,第二,因为快递“bodyParser()保存所有的文件到磁盘,然后像强大的其他模块必须从磁盘读取,而且我试图让文件直接上传到Rackspace CloudFiles,而不必先保存到磁盘。

阅读Formidable中的代码(连接,因此Express用于处理file upload),并以此为起点,修改不喜欢的行为(如保存到磁盘)。