2013的Sharepoint添加大容量文件REST API

问题描述 投票:2回答:1

我工作的一个项目,从一个文档库在Sharepoint 2013通过jQuery和REST API的文件复制到另一个。我的解决方案是基于关闭此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设置。
  • 新增的maxRequestLength = “2096128” executionTimeout = “999999” 在web.config中的httpRuntime
  • 增加了maxAllowedContendLength在web.config 2147483647
file rest file-upload upload sharepoint-2013
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.