这是我在开发 nodediscuss 的过程中实现的,现在单独拆分出来作为一个库,方便有文件上传需求的同学们。
GitHub: https://github.com/heroicyang/express-fileuploader
- 在上传成功之后自动删除临时文件(原因请参见这里)
- 不负责
multipart
解析,你可以自由选择multipart parser
- 插件式,可插拔
- 可根据自己的需求自定义上传逻辑(Strategy),比如将文件上传至
Dropbox
等
var gulp = require('gulp'); | |
var source = require('vinyl-source-stream'); | |
var browserify = require('browserify'); | |
var watchify = require('watchify'); | |
gulp.task('setWatch', function() { | |
global.isWatching = true; | |
}); | |
gulp.task('browserify', function() { |
{ | |
"vars": { | |
"@gray-base": "#000", | |
"@gray-darker": "lighten(@gray-base, 13.5%)", | |
"@gray-dark": "lighten(@gray-base, 20%)", | |
"@gray": "lighten(@gray-base, 33.5%)", | |
"@gray-light": "lighten(@gray-base, 46.7%)", | |
"@gray-lighter": "lighten(@gray-base, 93.5%)", | |
"@brand-primary": "darken(#428bca, 6.5%)", | |
"@brand-success": "#5cb85c", |
var id = 1; | |
(function loop (children) { | |
var nextChildren = []; | |
_.map(children, function (child) { | |
child.uid = child.name + '-' + id; | |
if (child.children && child.children.length > 0) { | |
nextChildren = nextChildren.concat(child.children); | |
} | |
id += 1; | |
}); |
function uniq (arr1, arr2) { | |
var result = arr1.concat(arr2) | |
, len = result.length; | |
for (var i = 0; i < len; i++) { | |
var firstIdx = result.indexOf(result[i]) | |
, lastIdx = result.lastIndexOf(result[i]); | |
while (firstIdx !== lastIdx) { | |
result.splice(lastIdx, 1); | |
len = len - 1; |
var _ = require('underscore') | |
, iconv = require('iconv-lite'); | |
var codes = [214,247,210,170,190,205,202,199,207,235,202,212,202,212,184,248,212,219,195,199,188,196,208,197,202,177,181,216,214,183,191,201,210,212,208,180,181,195,182,224,188,242,194,212,161,173,161,173]; | |
var str = _.map(codes, function (code) { | |
return String.fromCharCode(code); | |
}).join(''); | |
console.log(iconv.decode(new Buffer(str, 'ascii'), 'gbk')); |
Handlebars.registerHelper("debug", function(optionalValue) { | |
console.log("Current Context"); | |
console.log("===================="); | |
console.log(this); | |
if (optionalValue) { | |
console.log("Value"); | |
console.log("===================="); | |
console.log(optionalValue); | |
} | |
}); |
"jshint_options": | |
{ | |
"bitwise": false, | |
"camelcase": true, | |
"curly": true, | |
"eqeqeq": true, | |
"indent": 2, | |
"plusplus": true, | |
"undef": true, | |
"unused": true, |
# 终端中输入下面命令来打开 Chrome | |
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --winhttp-proxy-resolver |
{"whiteKeywords":[],"blackKeywords":[],"grayKeywords":[],"URLKeywords":[],"sourceKeywords":[],"sourceGrayKeywords":[],"userBlacklist":["1706976420"],"tipBackColor":"#FFD0D0","tipTextColor":"#FF8080","readerModeIndex":false,"readerModeProfile":false,"readerModeWidth":"750","readerModeBackColor":"rgba(100%, 100%, 100%, 0.8)","mergeSidebars":true,"floatSidebar":true,"unwrapText":true,"directBigImg":true,"directFeeds":false,"showAllGroups":true,"showAllMsgNav":true,"noDefaultFwd":true,"noDefaultGroupPub":true,"clearDefTopic":true,"overrideMyBack":false,"overrideOtherBack":false,"backColor":"rgba(100%, 100%, 100%, 0.2)","overrideMySkin":false,"overrideOtherSkin":false,"skinID":"skinvip001","filterOthersOnly":true,"filterPaused":false,"filterSmiley":false,"filterPromotions":true,"filterDeleted":true,"filterFeelings":true,"filterTaobao":false,"filterDupFwd":false,"maxDupFwd":"1","filterFlood":false,"maxFlood":"5","updateNotify":true,"autoSync":true,"floatBtn":true,"useCustomStyles":true,"customStyles":".WB_global_na |
这是我在开发 nodediscuss 的过程中实现的,现在单独拆分出来作为一个库,方便有文件上传需求的同学们。
GitHub: https://github.com/heroicyang/express-fileuploader
multipart
解析,你可以自由选择 multipart parser
Dropbox
等