2013-03-15 74 views
0

在使用JavaScript的Windows 8应用程序中,我尝试使用定义为in this technique的共享访问签名将文件上载到Windows Azure Blob存储,但我想使用WinRT BackgroundUploader而不是标准存储客户端上传器。当我调用此代码时,没有任何反应,并且存储容器在Windows Azure管理控制台中为空。在Windows Azure Blob存储中使用WinRT BackgroundUploader

有没有人做过这个?

有没有人有关于如何将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

首先,请设置BackgroundUploader.Method“把”,因为默认的“POST”方法不能用来上传一个blob。除此之外,请检查以下内容:

  • SAS令牌应具有写入权限。
  • 上传的文件必须小于64MB,因为这是Put Blob API所允许的最大限制。