【问题标题】:Upload file size limit with custom webscript on Alfresco Community 5.2在 Alfresco Community 5.2 上使用自定义 webscript 上传文件大小限制
【发布时间】:2020-02-12 04:56:10
【问题描述】:

我需要帮助才能通过共享 javascript 将文档内容上传回 Alfresco Community 5.2。 目标 noderef 已经存在,我上传了一个新版本的文档。

我无法使用api/upload web 服务,因为我还需要对 noderef 进行一些操作,并且我有一个需要转换的文件的 base64 内容。

所以我写了一个新的网页脚本,一切正常,至少在我上传小于 3MB 的文档时,

这是代码

 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
    });

我是否错过了一些增加最大上传文件大小的选项? 我尝试正常上传文件(通过拖放),它可以正常工作。

问题是当文件 >= 3MB 时,webscript 后面的 java 类没有收到任何字节

更新

经过一些研究,我发现这可能是数据如何通过 POST 传递的问题,因为 application/x-www-form-urlencoded 而不是 multipart/form-data,但我找不到指定方法ajax请求中的请求内容类型

解决方案

问题是 application/x-www-form-urlencoded 而不是 multipart/form-data,我使用了 here 所述的 fetch POST 请求,而且 ajax 请求解决方案也很好。

【问题讨论】:

    标签: alfresco alfresco-share alfresco-webscripts


    【解决方案1】:

    上周,我在 Alfresco 5.0.2.5 上遇到了与 Alfresco AJAX 请求非常相似的问题,我使用了 jquery 的 AJAX 调用,它对我有用。

     $.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) {
    
            }
        });
    

    参考链接:https://blog.arvixe.com/sending-multipart-form-using-ajax/

    希望对你有所帮助。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-28
    • 1970-01-01
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    相关资源
    最近更新 更多