Created
August 17, 2014 08:22
-
-
Save biggora/e1078c00c87e54de6bac to your computer and use it in GitHub Desktop.
Example uploading files middleware for TrinteJS framework
This file contains 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
/** | |
* Upload manager | |
* | |
* | |
* Created by init script | |
* App based on TrinteJS MVC framework | |
* TrinteJS homepage http://www.trintejs.com | |
**/ | |
var Uploader = require('express-uploader'); | |
var defaultOptions = { | |
debug: true, | |
validate: true, | |
thumbnails: true, | |
thumbToSubDir: true, | |
tmpDir: __dirname + '/tmp', | |
publicDir: __dirname + '/public', | |
uploadDir: __dirname + '/public/files', | |
uploadUrl: '/files/', | |
thumbSizes: [140, [100, 100]] | |
}; | |
exports.createDir = function(dirName) { | |
} | |
exports.middleware = function middleware(options) { | |
return function(req, res, next) { | |
var cOptions = MergeRecursive({}, defaultOptions); | |
cOptions = MergeRecursive(cOptions, options); | |
var uploader = new Uploader(cOptions); | |
uploader.uploadFile(req, function(data) { | |
res.send(data); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment