本文整理汇总了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)
}
)
}
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:59,代码来源:versioning.ts
示例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')
}
}
开发者ID:silentorb,项目名称:vineyard-cellar,代码行数:9,代码来源:cellar.ts
示例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(() => {});
}
开发者ID:loopingz,项目名称:webda-shell,代码行数:54,代码来源:http.ts
示例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
}
开发者ID:flowforever,项目名称:yaryin.note,代码行数:11,代码来源:app.ts
示例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));
}
开发者ID:mserranom,项目名称:lean-ci,代码行数:12,代码来源:api.ts
示例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
}
}
开发者ID:AckerApple,项目名称:ack-node,代码行数:15,代码来源:router.ts
示例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);
}
开发者ID:uhlryk,项目名称:horpyna-prototype-1,代码行数:27,代码来源:FileUpload.ts
示例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");
});
};
开发者ID:zalox,项目名称:Texd,代码行数:31,代码来源:upload.ts
示例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
开发者ID:stableShip,项目名称:fileUpload_demo,代码行数:30,代码来源:server.ts
示例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;
开发者ID:ffanzhang,项目名称:CheweyComicsContinued,代码行数:30,代码来源:index.ts
注:本文中的multer.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论