本文整理匯總了TypeScript中multer.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: setupRoutes
setupRoutes() {
this.router.get(
'/pending',
this._checkTokenHeader,
this._needPermissions('read', 'bot.ghost_content'),
async (req, res) => {
res.send(await this.ghost.forBot(req.params.botId).getPending())
}
)
this.router.get(
'/export',
this._checkTokenHeader,
this._needPermissions('read', 'bot.ghost_content'),
async (req, res) => {
const tarball = await this.ghost.forBot(req.params.botId).exportArchive()
const name = 'archive_' + req.params.botId.replace(/\W/gi, '') + '_' + Date.now() + '.tgz'
res.writeHead(200, {
'Content-Type': 'application/tar+gzip',
'Content-Disposition': `attachment; filename=${name}`,
'Content-Length': tarball.length
})
res.end(tarball)
}
)
const archiveUploadMulter = multer({
limits: {
fileSize: 1024 * 1000 * 100 // 100mb
}
})
// TODO WIP Partial progress towards importing tarballs from the UI
// this.router.get(
// '/import',
// this.checkTokenHeader,
// this.needPermissions('write', 'bot.ghost_content'),
// archiveUploadMulter.single('file'),
// async (req, res) => {
// const buffer = req['file'].buffer
// const botId = req.params.botId
// await this.ghost.forBot(botId).importArchive(buffer)
// res.sendStatus(200)
// }
// )
// Revision ID
this.router.post(
'/revert',
this._checkTokenHeader,
this._needPermissions('write', 'bot.ghost_content'),
async (req, res) => {
const revisionId = req.body.revision
const filePath = req.body.filePath
await this.ghost.forBot(req.params.botId).revertFileRevision(filePath, revisionId)
res.sendStatus(200)
}
)
}
示例2: require
initialize_services(app) {
var multer = require('multer')
app.use(multer({dest: this.config.paths.temp}))
var lawn = this.vineyard.bulbs.lawn
lawn.listen_user_http('/vineyard/upload', (req, res, user)=> this.upload(req, res, user))
if (this.config.paths.cache && this.config.templates) {
lawn.listen_user_http('/vineyard/cellar/:template/:guid.:ext', (req, res, user)=> this.file_download(req, res, user), 'get')
}
}
示例3: serve
async serve(port, websockets: boolean = false): Promise<Object> {
var http = require("http");
var express = require("express");
var cookieParser = require("cookie-parser");
var bodyParser = require("body-parser");
var multer = require("multer"); // v1.0.5
var upload = multer(); // for parsing multipart/form-data
var requestLimit = this.getGlobalParams().requestLimit
? this.getGlobalParams().requestLimit
: "20mb";
var app = express();
app.use(cookieParser());
app.use(
bodyParser.text({
type: "text/plain"
})
);
app.use(
bodyParser.json({
limit: requestLimit
})
);
app.use(
bodyParser.urlencoded({
extended: true
})
);
app.use(upload.array("file"));
// Will lower the limit soon, we should have a library that handle multipart file
app.use(
bodyParser.raw({
type: "*/*",
limit: requestLimit
})
);
app.set("trust proxy", "loopback, 10.0.0.0/8");
app.use(this.handleRequest.bind(this));
this.serveStaticWebsite(express, app);
this._http = http.createServer(app).listen(port);
if (websockets) {
// Activate websocket
this.output("Activating socket.io");
this._io = require("socket.io")(this._http);
this.emit("Webda.Init.SocketIO", this._io);
}
this.serveIndex(express, app);
this.output("Server running at http://0.0.0.0:" + port);
return new Promise(() => {});
}
示例4: initExpress
initExpress() {
var app = this.app;
//use nginx to serve static files on production
process.env.NODE_ENV !== 'production' && app.use(express['static'](__dirname + '/public'));
app.use(require('cookie-parser')('JuddTrump'))
app.use(require('cookie-session')({secret: 'a keyboard cat'}));
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({extended: true})); // for parsing application/x-www-form-urlencoded
app.use(multer()); // for parsing multipart/form-data
}
示例5: constructor
constructor() {
var express : any = require('express');
var bodyParser : any = require('body-parser');
var multer : any = require('multer');
this._app = express();
this._app.use(bodyParser.json()); // for parsing application/json
this._app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
this._app.use(multer()); // for parsing multipart/form-data
this._app.use(this.authenticate.bind(this));
}
示例6: function
module.exports.uploadOneByName = function(name, options){
options = paramUploadOptions(options)
const uploader = multer(options).single(name)
return function(req,res,next){
var promise = ack.promise()
.callback(function(callback){
uploader(req,res,callback)
})
if(next)promise = promise.then(next).catch(next)
return promise
}
}
示例7: createRoute
/**
* Tworzymy uchwyt dla route na moduł który będzie obsługiwał pliki
* Jako argument podajemy mu listę obiektów które mają {name:nazwa pola,count:licza plików na pole}
* @param {Object[]} fields [{name, count}]
* @return {any} zwraca middleware
*/
public createRoute(fields?: Object[]): any {
fields = fields || [];
var storageConfig = {};
if(this._directoryHandler){
storageConfig['destination'] = this._directoryHandler;
} else {
storageConfig['destination'] = this.directory;
}
if (this._filenameHandler){
storageConfig['filename'] = this._filenameHandler;
}
var storage = Multer.diskStorage(storageConfig);
return Multer({
storage: storage,
fileFilter: this._fileFilterHandler,
limits:{
fileSize: 1024 * 1024 * this._maxSize,//maksymalny rozmiar każdego pliku
files: this._maxFiles,//maksymalna liczba plików
}
}).fields(fields);
}
示例8: upload
}
callback(null, photoDirForDocId);
},
filename: function (req, file, callback) {
var originalName: string = ""
for (var index = 0; index < req.rawHeaders.length; index++) {
var element = req.rawHeaders[index];
if (element == "originalName") {
originalName = req.rawHeaders[index + 1];
// replace all whitespace with nothing
originalName = originalName.replace(/\s/g, "");
}
}
callback(null, originalName);
}
});
var saveUploadedFile = multer({ storage: storage }).single('photo');
export function upload(req, res) {
console.log("uploadfunc");
saveUploadedFile(req, res, function (err) {
console.log("saveUploadedFile Naa ");
if (err) {
return res.end("Error uploading file.");
}
res.end("File is uploaded");
});
};
示例9: require
var methodOverride = require('method-override');
var errorHandler = require('errorhandler');
var multer = require('multer');
var domainMiddleware = require('domain-middleware');
var app = express();
var server = require('http').createServer(app);
var mount = require('mount-routes');
app.use(cookieParser());
app.use(session({
secret: 'mEiriQAdmin_qianYun2015',
resave: true, // 強製session保存默認為true
saveUninitialized: true
}));
app.use(multer());//對multipart/form-data 類型數據進行處理
app.use(domainMiddleware({
server: server,
killTimeout: 10000
}));
app.set('port', process.env.PORT || 3006);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(bodyParser.urlencoded({
extended: false
})); //extended為true,使用node內置qs解析數據,false時使用querystring
示例10: require
var request = require('request');
var http = require('http');
var https = require('https');
var fs = require('fs');
var express = require('express');
var router = express.Router();
var User = userModel.repository;
var Comic = comicModel.repository;
var Page = pageModel.repository;
var Avatar = avatarModel.repository;
var jwt = require('jsonwebtoken');
var multer = require('multer');
var upload = multer({storage : multer.memoryStorage()});
var mongoose = require('mongoose');
var base64 = require('node-base64-image');
/* GET home page. */
router.get('/', accessController.renderIndex);
/* GET profile page. */
router.get('/myprofile', accessController.renderMyprofile);
/* GET someone elses profile page */
router.route('/aprofile/:user_id')
.get(function(req, res) {
var isloggedin = false;
var subd = false;