我想通过excel插件上传1G文件。但是当我使用Office.context.document.getFileAsync()时遇到了一些问题。
以不超过4194304字节(4 MB)的切片形式返回整个文档文件。希望文件可以成功上传。
但是当文件切片为No.256时,发生了错误。ErrorCode:12007.ErrorMessage:已从此主机窗口打开一个对话框,因此操作失败。 errorImg
函数getSlice中发生错误
function uploadRun() {
if (isCheckout) {
$("#msg").empty();
$('#uploadRun').addClass('disabled');
$('#uploadCancel').addClass('disabled');
$('#saveTemp').addClass('disabled');
} else {
$("#msg").empty();
$('#footer-div .btn-primary').attr('disabled', true);
}
Office.context.document.getFileAsync(
Office.FileType.Compressed,
{ },
function (result) {
if (result.status == Office.AsyncResultStatus.Succeeded) {
var myFile = result.value;
var state = {
file: myFile,
counter: 0,
sliceCount: myFile.sliceCount,
fileName: "",
result: true,
code: "",
msg: ""
};
getSlice(state);
} else {
showMessage(JSMsg["OfficeAddin.msg.00102"], false);
}
});
}
function getSlice(state) {
state.file.getSliceAsync(state.counter, function (result) {
if (result.status == Office.AsyncResultStatus.Succeeded) {
sendSlice(result.value, state);
} else if (result.status == Office.AsyncResultStatus.Failed) {
console.log(result);
showMessage("sliceCounter: " + state.counter + ".ERROR happened. ErrorCode: " + result.error.code + ".ErrorMessage:" + result.error.message, false);
}else {
showMessage(JSMsg["OfficeAddin.msg.00102"], false);
}
});
}