我有代码将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
- Unity Shader实现模糊效果 2023-04-27
- WPF使用DrawingContext实现绘制刻度条 2023-07-04
- 在C# 8中如何使用默认接口方法详解 2023-03-29
- 如何使用C# 捕获进程输出 2023-03-10
- user32.dll 函数说明小结 2022-12-26
- .NET CORE DI 依赖注入 2023-09-27
- C# 使用Aspose.Cells 导出Excel的步骤及问题记录 2023-05-16
- c# 模拟线性回归的示例 2023-03-14
- Unity3D实现渐变颜色效果 2023-01-16
- Oracle中for循环的使用方法 2023-07-04