Adds maxUploadSize option
This commit is contained in:
@@ -8,7 +8,7 @@ import Config from '../Config';
|
|||||||
|
|
||||||
export class FilesRouter {
|
export class FilesRouter {
|
||||||
|
|
||||||
getExpressRouter() {
|
getExpressRouter(options = {}) {
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
router.get('/files/:appId/:filename', this.getHandler);
|
router.get('/files/:appId/:filename', this.getHandler);
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ export class FilesRouter {
|
|||||||
|
|
||||||
router.post('/files/:filename',
|
router.post('/files/:filename',
|
||||||
Middlewares.allowCrossDomain,
|
Middlewares.allowCrossDomain,
|
||||||
BodyParser.raw({type: () => { return true; }, limit: '20mb'}), // Allow uploads without Content-Type, or with any Content-Type.
|
BodyParser.raw({type: () => { return true; }, limit: options.maxUploadSize || '20mb'}), // Allow uploads without Content-Type, or with any Content-Type.
|
||||||
Middlewares.handleParseHeaders,
|
Middlewares.handleParseHeaders,
|
||||||
this.createHandler
|
this.createHandler
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ function ParseServer({
|
|||||||
enableAnonymousUsers = true,
|
enableAnonymousUsers = true,
|
||||||
oauth = {},
|
oauth = {},
|
||||||
serverURL = '',
|
serverURL = '',
|
||||||
|
maxUploadSize = '20mb'
|
||||||
}) {
|
}) {
|
||||||
if (!appId || !masterKey) {
|
if (!appId || !masterKey) {
|
||||||
throw 'You must provide an appId and masterKey!';
|
throw 'You must provide an appId and masterKey!';
|
||||||
@@ -147,14 +148,16 @@ function ParseServer({
|
|||||||
var api = express();
|
var api = express();
|
||||||
|
|
||||||
// File handling needs to be before default middlewares are applied
|
// File handling needs to be before default middlewares are applied
|
||||||
api.use('/', new FilesRouter().getExpressRouter());
|
api.use('/', new FilesRouter().getExpressRouter({
|
||||||
|
maxUploadSize: maxUploadSize
|
||||||
|
}));
|
||||||
|
|
||||||
// TODO: separate this from the regular ParseServer object
|
// TODO: separate this from the regular ParseServer object
|
||||||
if (process.env.TESTING == 1) {
|
if (process.env.TESTING == 1) {
|
||||||
api.use('/', require('./testing-routes').router);
|
api.use('/', require('./testing-routes').router);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.use(bodyParser.json({ 'type': '*/*' }));
|
api.use(bodyParser.json({ 'type': '*/*' , limit: maxUploadSize }));
|
||||||
api.use(middlewares.allowCrossDomain);
|
api.use(middlewares.allowCrossDomain);
|
||||||
api.use(middlewares.allowMethodOverride);
|
api.use(middlewares.allowMethodOverride);
|
||||||
api.use(middlewares.handleParseHeaders);
|
api.use(middlewares.handleParseHeaders);
|
||||||
|
|||||||
Reference in New Issue
Block a user