上传后处理临时文件 [英] Handling Temporary Files after upload

查看:83
本文介绍了上传后处理临时文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个明确的应用程序,用户可以上传照片。我正在使用节点强大来处理上传部分。我也有node-graphicsmagick做这些照片的操纵,如创建缩略图,读取exif数据。节点强大的写入临时文件,node-graphicsmagick也是如此。然后我使用knox将照片上传到S3。

I have an express app where the users can upload photos. I am using node-formidable for handling the upload part. I also have node-graphicsmagick for doing manipulations on those photos like creating thumbnail, reading exif data. The node-formidable writes to a temporary file and so does node-graphicsmagick. I then upload the photos to S3 using knox.

我的问题是,在使用knox上传到S3之后,我无法理解如何处理临时文件。我知道如果我不处理它,那么它可能会导致问题,但不知道该怎么办?
请帮助我

My problem is I am not able to understand how to handle the temporary file after doing the upload to S3 using knox. I know if I don't handle it then it can cause problems but not being sure what to do?? Please help me.

使用流是一个选项,但我无法了解如何从节点强壮和节点图形流中流。流媒体也是一个很好的选择,我想知道它是否可能。

Using streams is an option but I am not able to understand how to stream from node-formidable and node-graphicsmagick. Streaming is also a good option and I want to know if its possible.

请帮助我。谢谢

推荐答案

只需删除它:

var fs = require('fs');
var tmpFN = req.files.yourFieldName.meta.path;
fs.unlink(tmpFN, function(err){
  if(err){ console.log(err); callback(err) }
  else { callback(null) };
}); 

这篇关于上传后处理临时文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆