Skip to content

Adds maxUploadSize option #604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Routers/FilesRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Config from '../Config';

export class FilesRouter {

getExpressRouter() {
getExpressRouter(options = {}) {
var router = express.Router();
router.get('/files/:appId/:filename', this.getHandler);

Expand All @@ -19,7 +19,7 @@ export class FilesRouter {

router.post('/files/:filename',
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,
this.createHandler
);
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function ParseServer({
enableAnonymousUsers = true,
oauth = {},
serverURL = '',
maxUploadSize = '20mb'
}) {
if (!appId || !masterKey) {
throw 'You must provide an appId and masterKey!';
Expand Down Expand Up @@ -147,14 +148,16 @@ function ParseServer({
var api = express();

// 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
if (process.env.TESTING == 1) {
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.allowMethodOverride);
api.use(middlewares.handleParseHeaders);
Expand Down