我正在尝试通过blob发送二进制数据...但它似乎与我在发送之前的base64时相同...似乎某种程度上它在飞行中从UTF8转换为UTF16 ......或者别的......
function upload(blobOrFile) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://...:P', true);
xhr.onload = function(e) { alert('ok'); };
// Listen to the upload progress.
var progressBar = document.querySelector('progress');
xhr.upload.onprogress = function(e) {
if (e.lengthComputable) {
progressBar.value = (e.loaded / e.total) * 100;
progressBar.textContent = progressBar.value; // Fallback for unsupported browsers.
}
};
xhr.send(blobOrFile);
}
upload(new Blob([binary_data_string], {type: 'application/octet-stream'}));
我到底错过了什么/做错了什么?
真实示例