Skip to content

Unable to upload base64 encoded file [Error: request entity too large] #536

Description

@tanmays

Hello,

I'm using the latest parse-server release v2.1.2 and S3Adapter for saving files. I'm trying to upload a base64 encoded image but I am facing the following error:

Uncaught internal server error. { [Error: request entity too large]
  expected: 273231,
  length: 273231,
  limit: 102400,
  message: 'request entity too large',
  status: 413,
  statusCode: 413,
  type: 'entity.too.large' } Error: request entity too large
    at readStream (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/body-parser/node_modules/raw-body/index.js:196:17)
    at getRawBody (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/body-parser/node_modules/raw-body/index.js:106:12)
    at read (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/body-parser/lib/read.js:76:3)
    at jsonParser (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/body-parser/lib/types/json.js:121:5)
    at Layer.handle [as handle_request] (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/express/lib/router/index.js:312:13)
    at /Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/express/lib/router/index.js:330:12)
    at next (/Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/express/lib/router/index.js:271:10)
    at /Users/tanmay/parse-server/parse-server-example/node_modules/parse-server/node_modules/express/lib/router/index.js:618:15

My cloud code is:

Parse.Cloud.define("UploadImageAndGetURL", function(request, response) {

  var fileName = request.params.fileName;
  var base64 = request.params.base64EncodedImageString;

  var file = new Parse.File(fileName, { base64: base64 });

  file.save(null, {useMasterKey:true}).then(function(fileObject) {
      // The file has been saved to Parse.
      var photoURL = fileObject.url();
      console.log("Photo saved successfully with URL:" + photoURL);
      response.success(photoURL);
    }, function(error) {
      // The file either could not be read, or could not be saved to Parse.
      console.log("The file either could not be read, or could not be saved to Parse:" + JSON.stringify(error));
      response.error(error);
  });

});

There is a previously reported issue: #53 when I change the following:

in file parse-server/lib/index.js:line:147

from
api.use(bodyParser.json({ 'type': '*/*' }));
to
api.use(bodyParser.json({ 'type': '*/*',limit: '20mb' }));

file uploading works again.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions