none
[Node.js][Azure Storage] How to get SAS to upload to blob ? RRS feed

  • Question

  • Hi. i used Mobile Service in the past.

    and now i am trying to use Mobile App .

    When i use Mobile Service, i used Blob service and SAS.

    but now i have problem in Mobile App

    The problem is i can't upload with SAS,

    when i try to upload it make error..

    Caused by: java.lang.IllegalArgumentException: Cannot provide credentials as part of the address and as constructor parameter. Either pass in the address or use a different constructor.

    I am losing long time for it :( ..

    In Azure reference, there are exist about Mobile Service SAS, not Mobile App. (or i can't find??)

    Hope your help, Thanks you

    it is my android code

    mTodoItem.insert(todoItem).get();
    if (todoItem.getmSasQueryString() != null) {
    StorageCredentials cred = new StorageCredentialsSharedAccessSignature(todoItem.getmSasQueryString());
    URI imageUri = new URI(todoItem.getmImage());
    CloudBlockBlob blobFromSASCredential = new CloudBlockBlob(imageUri, cred);
    blobFromSASCredential.uploadFromFile(realPath);
    }

    and it is my azure code

    table.insert(function (context) { 
        
      var blobService = azure.createBlobService(accountName, accountKey);
          blobService.createContainerIfNotExists('images', {publicAccessLevel : 'blob'}, 
              function(error, result, response){
              if (!error) {console.log("Created");} 
            });
            
       var sharedAccessPolicy = {
            AccessPolicy: {
                Permissions: azure.BlobUtilities.SharedAccessPermissions.WRITE,
                Expiry: new Date(new Date().getTime() + 5 * 60 * 1000)
            }
        };
        
        // Generate the upload URL with SAS for the new image.
        var sasQueryUrl = blobService.generateSharedAccessSignature('images', context.item.resourcename, sharedAccessPolicy);
                  
        // Set the query string.
        context.item.sasquerystring = sasQueryUrl;
        
        // Set the full path on the new new item, 
        context.item.image = blobService.getUrl('images', context.item.id, sasQueryUrl);
        // which is used for data binding on the client. 
              
      return context.execute();
    });




    Friday, May 13, 2016 1:09 PM

All replies