【问题标题】:Sharepoint 2013 Add large files with rest apiSharepoint 2013 使用 rest api 添加大文件
【发布时间】:2014-08-17 19:06:20
【问题描述】:

我正在开发一个项目,通过 jquery 和其他 api 在 Sharepoint 2013 中将文件从一个文档库复制到另一个文档库。我的解决方案基于http://techmikael.blogspot.com/2013/07/how-to-copy-files-between-sites-using.html

以下代码适用于较小的文件大小(64mb 或更小)。但是,在尝试复制较大的文件(128Mb 及以上)时出现错误。 addFileBinary 函数以“没有足够的存储空间来完成此操作”返回错误回调。有解决方法吗?我使用的是 IE11。

$(document).ready(function () 
{
    //Get binary data of file to copy
    getFileBinary(fromUrl, FileServerRelativeUrl, function (binary) 
    {    
        //Copy binary file data to new library
        addFileBinary(toUrl, newLibraryName, FileName, binary, function (newFile) 
        {
            alert("File Added");
        },null);

    },null);
}


function getFileBinary(url, filePath, complete, failure) 
{
    var executor = new SP.RequestExecutor(url);
    var info = {
        url: "_api/web/getfilebyserverrelativeurl('" + filePath + "')/$value",
        method: "GET",
        binaryStringResponseBody: true,
        success: function (data) {
            //binary data available in data.body
            complete(data.body);
        },
        error: function (err) {
            failure(err);
        }
    };
    executor.executeAsync(info);
}

function addFileBinary(url, libraryName, fileName, arrayBuffer, complete, failure) {
    var executor = new SP.RequestExecutor(url);
    var info = {
        url: "_api/web/GetFolderByServerRelativeUrl('" + libraryName + "')/Files/Add(url='" + fileName + "', overwrite=true)?$expand=ListItemAllFields,ListItemAllFields/ParentList",
        headers: {
            "Accept": "application/json; odata=verbose",
            "content-length": arrayBuffer.length,
        },
        method: "POST",
        contentType: "application/json;odata=verbose",
        binaryStringRequestBody: true,
        body: arrayBuffer,
        state: 'Update',
        success: function (data) {
            var jsonObj = $.parseJSON(data.body);
            complete(jsonObj.d);
        },
        error: function (err) {
            failure(err);
        }
    };
    executor.executeAsync(info);
}

我已执行以下操作以尝试纠正此问题(均无效)。

  • 更改了 Web 应用程序的常规设置以允许最大为 2047 的文件。
  • 在 iis 中为 Sharepoint 增加了连接超时设置。
  • 在 web.config 中的 httpruntime 中添加了 maxRequestLength="2096128" executionTimeout="999999"
  • 将 web.config 中的 maxAllowedContendLength 增加到 2147483647

【问题讨论】:

    标签: file rest file-upload upload sharepoint-2013


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    • 1970-01-01
    • 2015-11-30
    • 1970-01-01
    相关资源
    最近更新 更多