它实际上很直接。提交阻止列表时,您将元数据键/值对作为请求标头的一部分传递。
例如,假设您有2个元数据键/值对: key1/value1 和 key2/value2 。这是您的提交阻止列表代码的样子:
key1/value1
key2/value2
function commitBlockList() { var uri = submitUri + '&comp=blocklist'; console.log(uri); var requestBody = '<?xml version="1.0" encoding="utf-8"?><BlockList>'; for (var i = 0; i < blockIds.length; i++) { requestBody += '<Latest>' + blockIds[i] + '</Latest>'; } requestBody += '</BlockList>'; console.log(requestBody); $.ajax({ url: uri, type: "PUT", data: requestBody, beforeSend: function (xhr) { xhr.setRequestHeader('x-ms-blob-content-type', selectedFile.type); xhr.setRequestHeader('Content-Length', requestBody.length); xhr.setRequestHeader('x-ms-meta-key1', 'value1'); xhr.setRequestHeader('x-ms-meta-key2', 'value2'); }, success: function (data, status) { console.log(data); console.log(status); }, error: function (xhr, desc, err) { console.log(desc); console.log(err); } }); }
供参考,请参阅 Put Block List REST API文档: https://docs.microsoft.com/en-us/rest/api/storageservices/Put-Block-List
Put Block List