Increasing max file size

3,526 views
Skip to first unread message

Curtis Floth

unread,
Oct 21, 2014, 11:57:15 AM10/21/14
to loopb...@googlegroups.com
What is the proper way to increase the maximum file size allowed for file uploads? I'm currently seeing this result using the loopback-component-storage module:

{
    "error": {
        "name": "Error",
        "status": 413,
        "message": "request entity too large",
        "type": "entity.too.large",
        "statusCode": 413,
        "expected": 413740,
        "length": 413740,
        "limit": 102400
    }
}


Chregan O'Flynn

unread,
Oct 21, 2014, 12:23:58 PM10/21/14
to loopb...@googlegroups.com

Hey, 

I had a similar problem and solved it by adding the following to my server/server.js file:
app.use(loopback.bodyParser.json({limit: '50mb'}));
app
.use(loopback.bodyParser.urlencoded({limit: '50mb', extended: true}));

Let me know if that helps

Chregan

Raymond Feng

unread,
Oct 21, 2014, 12:43:45 PM10/21/14
to Curtis Floth, loopb...@googlegroups.com
What’s the stack trace?

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raymond Feng

unread,
Oct 21, 2014, 12:47:33 PM10/21/14
to Chregan O'Flynn, loopb...@googlegroups.com
For json/urlencoded limit, it’s recommended to configure them in server/config.json as follows:

{
  “remoting”: {
   “json”: {“limit”: “50mb”},
   “urlencoded”: {“limit”: “50mb”, “extended”: true}
  }
}

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

Raymond Feng

unread,
Oct 21, 2014, 1:31:24 PM10/21/14
to Curtis Floth, loopb...@googlegroups.com
Are you sending JSON data (Content-Type: application/json)? I thought you are trying to upload a file.

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

On Oct 21, 2014, at 10:20 AM, Curtis Floth <cur...@circlecf.com> wrote:

{
   "error": {
       "name": "Error",
       "status": 413,
       "message": "request entity too large",
       "type": "entity.too.large",
       "statusCode": 413,
       "expected": 344382,
       "length": 344382,
       "limit": 102400,
       "stack": "Error: request entity too large\n    at makeError
(/Users/cfloth/loopback/node_modules/loopback/node_modules/strong-remoting/node_modules/body-parser/node_modules/raw-body/index.js:184:15)\n
  at module.exports
(/Users/cfloth/loopback/node_modules/loopback/node_modules/strong-remoting/node_modules/body-parser/node_modules/raw-body/index.js:40:15)\n
  at read (/Users/cfloth/loopback/node_modules/loopback/node_modules/strong-remoting/node_modules/body-parser/lib/read.js:62:3)\n
  at jsonParser
(/Users/cfloth/loopback/node_modules/loopback/node_modules/strong-remoting/node_modules/body-parser/lib/types/json.js:85:5)\n
  at Layer.handle [as handle_request]
(/Users/cfloth/loopback/node_modules/loopback/node_modules/express/lib/router/layer.js:76:5)\n
  at trim_prefix
(/Users/cfloth/loopback/node_modules/loopback/node_modules/express/lib/router/index.js:263:13)\n
  at /Users/cfloth/loopback/node_modules/loopback/node_modules/express/lib/router/index.js:230:9\n
  at Function.proto.process_params
(/Users/cfloth/loopback/node_modules/loopback/node_modules/express/lib/router/index.js:305:12)\n
  at /Users/cfloth/loopback/node_modules/loopback/node_modules/express/lib/router/index.js:221:12\n
  at Function.match_layer
(/Users/cfloth/loopback/node_modules/loopback/node_modules/express/lib/router/index.js:288:3)"

Michael Blakeney

unread,
Apr 17, 2015, 7:09:45 PM4/17/15
to loopb...@googlegroups.com
I'm getting the same error for my file uploads as well.  Here's the configs I'm using:

  "json": {
      "strict": false,
      "limit": "50mb"
    },
    "urlencoded": {
      "extended": true,
      "limit": "50mb"
    }

I'm uploading mp3 files that are 14mb to 15mb onto an S3 bucket.  Smaller files successfully upload.


Thanks,
Mike Blakeney

Pulkit Singhal

unread,
Apr 17, 2015, 9:53:38 PM4/17/15
to loopb...@googlegroups.com
I too was running into:

ERROR { [Error: request entity too large]
  cause: 
   { [Error: request entity too large]
     name: 'Error',
     status: 413,
     statusCode: 413,
     expected: 125798,
     length: 125798,
     limit: 102400 },
  isOperational: true,
  status: 413,
  statusCode: 413,
  expected: 125798,
  length: 125798,
  limit: 102400 }

And adding the following to config.json worked!

Michael Blakeney

unread,
Apr 17, 2015, 11:29:47 PM4/17/15
to loopb...@googlegroups.com
Hi Pulkit,
Thanks for the suggestion.  I removed the "strict":false parameter like you suggested but still get the error.  I noticed that the error I'm getting is different than the one you were getting.  Here's my error:
[Error: maxFileSize exceeded, received 10502003 bytes of field data (max is 10485760)]

Any ideas?  

Mike B.

Benjamin Boudreau

unread,
Apr 18, 2015, 12:25:15 PM4/18/15
to loopb...@googlegroups.com
By default, the storage component limits file sizes to 10mb you can set an option on the upload handler or storage datasource to increase it.

Pisit Tangkoblarp

unread,
May 7, 2015, 3:21:18 AM5/7/15
to loopb...@googlegroups.com
You can set an option for this by add the line 

"maxFileSize": "52428800"

(52428800 is 50mb)

to your datasource.json file, like this:

"storageDS": {
   
"name": "xxxxx",
   
"connector": "loopback-component-storage",
   
"provider": "azure",
   
"storageAccount": "xxxxxxxx",
   
"storageAccessKey": "xxxxxx",
   
"maxFileSize": "52428800"
 
}

Pisit Tangkoblarp

unread,
May 7, 2015, 3:25:23 AM5/7/15
to loopb...@googlegroups.com
For Loopback team, please update this key and other keys (if any) to the storage component documentation (http://docs.strongloop.com/display/public/LB/Storage+component).

I have to dig to the code to know this "maxFileSize" option key.

Thanks

narasimha rao

unread,
May 18, 2016, 9:03:56 AM5/18/16
to LoopbackJS
Thanks, It worked for me.
Reply all
Reply to author
Forward
0 new messages