我有代码将blob插入存储,并允许用户查看blob列表和单个blob.但是,我现在无法删除blob,出现的错误是“System.ServiceModel.ni.dll中出现’System.ServiceModel.FaultException`1’类型的异常,但未在用户代码中处理.附...

我有代码将blob插入存储,并允许用户查看blob列表和单个blob.但是,我现在无法删除blob,出现的错误是
“System.ServiceModel.ni.dll中出现’System.ServiceModel.FaultException`1’类型的异常,但未在用户代码中处理.附加信息:远程服务器返回错误:(404)Not Found.”
WCF服务中的代码是
public void DeleteBlob(string guid, string uri)
{
//create the storage account with shared access key
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(accountDetails);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(guid);
CloudBlockBlob blob = container.GetBlockBlobReference(uri);
blob.DeleteIfExists();
}
然后我通过SOAP服务在移动客户端应用程序中访问它,如:
private void mnuDelete_Click(object sender, EventArgs e)
{
MessageBoxResult message = MessageBox.Show("Are you sure you want to delete this image?", "Delete", MessageBoxButton.OKCancel);
if (message == MessageBoxResult.OK)
{
Service1Client svc = new Service1Client();
svc.DeleteBlobCompleted += new EventHandler<AsyncCompletedEventArgs>(svc_DeleteBlobCompleted);
svc.DeleteBlobAsync(container, uri);
}
}
void svc_DeleteBlobCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Error == null) {
NavigationService.Navigate(new Uri("/Pages/albums.xaml", UriKind.Relative));
}
else {
MessageBox.Show("Unable to delete this photo at this time", "Error", MessageBoxButton.OK);
}
}
我也首先使用SAS令牌来保存blob – 我不知道这是否有所作为?
解决方法:
在Azure Storage Client Library 4.0中,我们更改了Get * Reference方法以仅接受相对地址.因此,如果您使用的是最新的库且参数“uri”是绝对地址,则应将其更改为blob名称,或者应使用带有Uri和StorageCredentials对象的CloudBlockBlob constructor.
请查看我们GitHub repository中所有这些重大变化.
本文标题为:在c#中从Windows azure中删除blob


基础教程推荐
- C#集合查询Linq在项目中使用详解 2023-06-09
- C# Winform实现石头剪刀布游戏 2023-01-11
- 京东联盟C#接口测试示例分享 2022-12-02
- c#读取XML多级子节点 2022-11-05
- Unity shader实现多光源漫反射以及阴影 2023-03-04
- C#中类与接口的区别讲解 2023-06-04
- C#通过GET/POST方式发送Http请求 2023-04-28
- c#中利用Tu Share获取股票交易信息 2023-03-03
- C# – NetUseAdd来自Windows Server 2008和IIS7上的NetApi32.dll 2023-09-20
- 使用c#从分隔文本文件中插入SQL Server表中的批量数据 2023-11-24