Created
August 28, 2014 02:12
-
-
Save iamblue/647c508bda587dd50737 to your computer and use it in GitHub Desktop.
aaa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var s3 = new AWS.S3(); | |
| var _now = new Date(); | |
| var sArray = req.files.file.name.split(/(.jpg|.gif|.png|.jpeg)/); | |
| var _re = crypto.createHash('md5').update(sArray[0]+_now).digest("hex"); | |
| _re = _re+sArray[1]; | |
| fs.readFile('/'+req.files.file.path, function (_err, data) { | |
| var params = {Bucket: 'limitstyle',Key:_re,Body:data,ACL: 'public-read'}; | |
| s3.putObject(params, function (err, data) { | |
| if (err) { | |
| } else { | |
| gm('/'+req.files.file.path).size(function(err,size){ | |
| if(!err){ | |
| fs.unlink('/'+req.files.file.path, function() { | |
| if (err) throw err; | |
| if(size.width == 974 && size.height ==400 ){ | |
| res.send({n:_re,width:size.width,height:size.height}); | |
| }else{ | |
| var params = {Bucket: 'limitstyle',Key:_re}; | |
| s3.deleteObject(params,function(err,data){ | |
| }); | |
| res.send({n:'error'}); | |
| } | |
| }); | |
| } | |
| }); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment