Upload image file size

Enonic version: 6.14.0
OS: Centos 6


I’m using libs.portal.getMultipartStream(‘file’) to upload image, but it fails when trying uploading image about 2 MB. I got “Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)” .

How can I increase allowed file size?

Below is the code of this upload service:

  • Upload image to the folder Images of the site.
    var libs = {
    portal: require(’/lib/xp/portal’),
    content: require(’/lib/xp/content’)

exports.post = function(req) {
var imageMetadata = libs.portal.getMultipartItem(‘file’);
var imageFile = libs.portal.getMultipartStream(‘file’);

var createResult = libs.content.createMedia({
	name: imageMetadata.fileName,
	parentPath: '/' + app.config.sitename + '/images',
	mimeType: imageMetadata.contentType,
	branch: 'draft',
	data: imageFile

var publishResult = libs.content.publish({
	keys: [createResult._id],
	sourceBranch: 'draft',
	targetBranch: 'master',
	includeChildren: true,
	includeDependencies: false

var message = null;
if (publishResult) {
	var imageUrl = libs.portal.imageUrl({path: createResult._path, scale: 'width(556)'});
	message = imageUrl;

return {
	body: {
		result: message
	contentType: 'application/json; charset=utf-8'



This is usually due to the config on the proxy/webserver in front. I don’t think apache limits this (or at least the limit is quite high).

Nginx has default limit of 2MB, if no client_max_body_size is set.
So for nginx you would have to set client_max_body_size within the http bracket of nginx.conf

user  nginx;
worker_processes  auto;

events {

http {
    client_max_body_size 100M;
1 Like