alfrescoalfresco-sharealfresco-webscripts

Upload file size limit with custom webscript on Alfresco Community 5.2


I need help to upload document content back in Alfresco Community 5.2 though a share javascript. The destination noderef is already existing, I upload a new version of a document.

I can't use the api/upload web service because I also need to do some operation on the noderef and I have a base64 content of the file which need to be converted.

So I wrote a new webscript and it is all working fine, at least while I upload documents which are smaller than 3MB,

Here it is the code

 Alfresco.util.Ajax.request({
        method: Alfresco.util.Ajax.POST,
        dataObj: {
            bytes: response.bytes,
            digestAlgorithm: response.digestAlgorithm,
            mimeType: response.mimeType.mimeTypeString,
            name: response.name,
            nodeRef: this.nodeRef,
            signatureLevel: this.signatureLevel
        },
        url: thisClass.urlAlfrescoService + "myOrg/myPackage/uploadDocument",

        successCallback: {
            fn: thisClass._successOnUploadContent,
            scope: this
        },

        failureCallback: {
            fn: thisClass._errorOnUploadContent,
            scope: this
        },

        scope: this,
        noReloadOnAuthFailure: true
    });

Do I miss some option to increase max upload file size? I tryed uploading the file normally (with drag and drop) and it works.

The problem is when the file is >= 3MB the java class behind the webscript does not receive any byte

UPDATE

After some researches I found it could be a problem of how data are passed through POST, as application/x-www-form-urlencoded instead of multipart/form-data, but I can't find a way to specify the request content type in the ajax request

SOLUTION

The problem was the application/x-www-form-urlencoded instead of the multipart/form-data, I used a fetch POST request as stated here, but also the ajax request solution is good.


Solution

  • Last week,I had a same very similar problem with Alfresco AJAX request on Alfresco 5.0.2.5 and I used jquery's AJAX calls and it worked for me.

     $.ajax({
            url: Alfresco.constants.PROXY_URI + "your_web_script",
            type: "POST",
            data: dataFromFiles,
            mimeType: "multipart/form-data",
            contentType: false,
            cache: false,
            processData: false,
            dataType: "text",
            success: function(data, textStatus, jqXHR) {
    
            },
            error: function(jqXHR, textStatus, errorThrown) {
    
            }
        });
    

    Reference link : https://blog.arvixe.com/sending-multipart-form-using-ajax/

    Hope this helps you.