我正在尝试将 Revit 文件逐块发送到我的 Bucket 块。我的 Revit 文件将近 13 MB。这是我的代码:
function handleFileSelect(evt) {
var files = evt.target.files;
var file = files[0];
var segmentSize = 1024 * 1024 * 5; //5 MB
var startingByte = 0;
var endingByte = startingByte + segmentSize - 1;
var segments = Math.ceil(file.size / segmentSize);
var session = Math.floor(100000000 + Math.random() * -900000000);
for (var i = 0; i < segments; i ++)
{
var blob = file.slice(startingByte, endingByte);
var url = 'https://developer.api.autodesk.com/oss/v2/buckets/' + 'linked_model' + '/objects/' + file.name + '/resumable';
//console.log(url);
var contentRange = 'bytes ' + startingByte + '-' + endingByte + '/' + file.size;
$.ajax({
type: 'PUT',
url: url,
data: blob,
headers: {
'Authorization':'Bearer ' + token,
'Content-Type':'application/octet-stream',
'Content-Range': contentRange,
'Session-Id': session
},
crossDomain: true,
processData: false,
success: function (data) {
console.log(i);
startingByte = endingByte + 1;
endingByte = startingByte + segmentSize - 1;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
console.log(startingByte);
console.log(endingByte);
console.log(file.size);
}
});
}
}
它给了我错误:416(请求的范围不满足)
任何人都可以帮忙吗?