[Node.js] [Azure存储]如何让SAS上传到blob? [英] [Node.js][Azure Storage] How to get SAS to upload to blob ?
问题描述
您好。我过去使用过移动服务。
现在我正在尝试使用移动应用程序。
当我使用移动服务时,我使用了Blob服务和SAS。
但现在我在移动应用程序中遇到问题
问题是我无法使用SAS上传,
当我尝试上传时发生错误..
引起:java.lang.IllegalArgumentException:无法提供凭据作为地址和构造函数参数的一部分。传递地址或使用不同的构造函数。
我失去了很长时间:( ..
在Azure参考中,存在关于移动服务SAS,而不是移动应用程序。(或者我找不到??)
希望你的帮助,谢谢你
这是我的安卓代码
mTodoItem .insert( todoItem )。get();
if ( todoItem .getmSasQueryString()!= null ){
StorageCredentials cred = new StorageCredentialsSharedAccessSignature( todoItem .getmSasQueryString());
URI imageUri = 新 URI( todoItem .getmImage());
CloudBlockBlob blobFromSASCredential = new CloudBlockBlob(imageUri,cred);
blobFromSASCredential。 uploadFromFile ( realPath );
}
和它是我的天蓝色代码
table.insert(function(context){
var blobService = azure.createBlobService(accountName,accountKey);
blobService.createContainerIfNotExists('images',{publicAccessLevel:'blob'},
function(错误,结果,回复){
if(!error){console.log("已创建");}
});
var sharedAccessPolicy = {
AccessPolicy:{
$
Permissions : azure.BlobUtilities.SharedAccessPermissions.WRITE,
         到期日:新日期(新日期()。getTime()+ 5 * 60 * 1000)
      }¥b $ b   };
  //使用SAS为新图片生成上传网址。
  var sasQueryUrl = blobService.generateSharedAccessSignature('images',context.item.resourcename,sharedAccessPolicy);
         
  //设置查询字符串。
  context.item.sasquerystring = sasQueryUrl;
  //设置新新项目的完整路径,
  context.item.image = blobService.getUrl('images',context.item.id,sasQueryUrl);
  //用于客户端的数据绑定。
     
return context.execute();
});
< blockquote>
Hi Cooksunghun,
也许这个在线Microsoft文档可以帮助你:
创建并使用带有Blob存储的SAS: a href ="https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-2/">
https://azure.microsoft。 com / zh-CN / documentation / articles / storage-dotnet-shared-access-signature-part-2 /
希望这对您有所帮助,
最诚挚的问候,
@Jamesvandenberg
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();
});
Hi Cooksunghun,
Maybe this Online Microsoft documentation can help you out :
Create and use a SAS with Blob storage : https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-2/
Hope this is helpful for you,
Best Regards,
@Jamesvandenberg
这篇关于[Node.js] [Azure存储]如何让SAS上传到blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!