尝试开发一个Xamarin Forms移动应用程序,该应用程序通过api显示存储在Azure-Storage容器中的blobs。
当前流程如下: API > Azure-Storage Blob >显示在Xamarin移动应用程序中。
使用存储帐户密钥连接到azure存储。
问题是,当容器上的公共访问设置为“private”时,blob不会显示在移动应用程序中。如果容器公共访问设置为“blob”,则照片将显示在xamarin Mobile应用程序中。
图片用于说明目的。Photo of issue
代码如下。
string storageConnectionString
Environment.GetEnvironmentVariable("storageconnectionstring");
CloudStorageAccount storageAccount;
if (CloudStorageAccount.TryParse(storageConnectionString, out
storageAccount))
{
// If the connection string is valid, proceed with operations against
Blob storage here.
...
}
else
{
//Error
}
[enter image description here][1]CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();如何将容器设置为私有,同时仍然在移动应用程序中显示blob?
发布于 2019-05-30 09:32:11
我认为你可能使用了错误的Azure blob存储连接。
您需要使用共享密钥。
shared key authentication with azure blob storage
您将需要生成新的共享访问签名。
我希望这为您指明了正确的方向。
发布于 2019-05-31 06:49:09
非常感谢您的帮助@justjoshin。
SAS就是答案。在那里,您可以生成一个SAS令牌,将其附加在blob url之后以显示它,即使容器是私有的也是如此。
希望这对任何人都有帮助。
最好的
https://stackoverflow.com/questions/56370197
复制相似问题