在使用 JavaScript 的 Windows 8 应用程序中,我尝试使用此技术中定义的共享访问签名将文件上传到 Windows Azure Blob 存储,但我想使用 WinRT BackgroundUploader 而不是标准存储客户端上传器。当我调用此代码时,没有任何反应,并且 Windows Azure 管理控制台中的存储容器为空。
有没有人这样做过?
有人对我应该如何将 SAS 放入 BackgroundUploader 的 serverCredential 属性有建议吗?
table.insert(upload)
.then(function (e) {
var backgroundTransfer = Windows.Networking.BackgroundTransfer,
uploader = new backgroundTransfer.BackgroundUploader(),
uri = new Windows.Foundation.Uri(upload.sas),
operation,
sasToken = uri.query.substr(1);
uploader.setRequestHeader("Content-Type", file.contentType);
uploader.setRequestHeader("x-ms-blob-type", "BlockBlob");
operation = uploader.createUpload(uri, file);
operation.startAsync().then(function (uploadComplete) {
console.info(uploadComplete);
complete("https://" + uri.host + "/" + upload.containerName + "/" + file.name);
},
function (uploadError) {
console.error(uploadError);
},
function (uploadProgress) {
console.info(uploadProgress);
});