在使用JavaScript的Windows 8应用中,我尝试使用共享访问签名in this technique将文件上传到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);
});
答案 0 :(得分:0)
首先,请将BackgroundUploader.Method设置为“PUT”,因为默认的“POST”方法不能用于上传blob。除此之外,请检查以下内容: