我工作的一个项目,从一个文档库在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);
}
我已经做了以下尝试解决此问题(它没有工作)。
我会建议使用SharePoint的API。试试这些:
https://sharepoint.stackexchange.com/questions/104860/sharepoint-online-rest-api-image-upload-ajax