c# - 在上传到 AzureCloud BlobStorage 时为 UNIT_TESTCASE 命名一个异常
问题描述
在上传到 AzureCloud BlobStorage 时为 UNIT_TESTCASE 命名一个异常。
我的代码是,
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container =
blobClient.GetContainerReference("myblogcontainer");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob =
container.GetBlockBlobReference("WeekendChamps.jpg");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream =
System.IO.File.OpenRead(@"C:\Users\Bliss\Downloads\WeekendChamps.jpg"))
{
blockBlob.UploadFromStream(fileStream);
}
解决方案
在 try catch 块中捕获StorageException,在 catch 块中您可以处理异常以获取 RequestInformation 和 StorageExtendedErrorInformation。
BlobErrorCodeStrings类中为 Blob 定义了各种异常代码。您可以对错误代码进行切换,也可以尝试匹配您需要的任何特定错误代码。
推荐阅读
- javascript - 图表 js,圆环图未正确呈现顶部提示
- r - 这种独特/过滤语法如何工作?
- c# - 无法将父画布适合子文本
- firebase - 如何从 Flatlist 中的 firebase 实时数据库中检索所有数据用户照片?
- swagger - 如何修复 OpenAPI 上不允许的附加属性?
- html - 下拉菜单列表位置和宽度与 Safari 浏览器中的下拉菜单不同
- strapi - 如何修复 Strapi Meilisearch 插件?
- javascript - 如何修复此导航栏 JavaScript 代码?
- azure - 从 azure 活动目录创建后,永远不要要求重置密码
- python - 有没有办法加载一个
使用 geopandas 的对象?