[英]C# not retrieving blob from Azure blob storage
I have a series of blobs which I would like to process. 我有一系列我想要处理的blob。 My program is getting a 404 error, throwing an exception like this:
我的程序收到404错误,抛出这样的异常:
ErrorCode:BlobNotFound
ErrorMessage:The specified blob does not exist.
The access policy on the container is set properly, and when I paste the logged URI into my browser (for instance, this: https://atpblob.blob.core.windows.net/darkskydata/plot1251time2010-01-02t00:00:01z.json
), it downloads fine. 正确设置了容器上的访问策略,当我将记录的URI粘贴到我的浏览器中时(例如,这个:
https://atpblob.blob.core.windows.net/darkskydata/plot1251time2010-01-02t00:00:01z.json
),它下载得很好。
Here is the relevant code: 这是相关代码:
Console.WriteLine(daily.BlobUri);
CloudBlockBlob blockBlob = container.GetBlockBlobReference(daily.BlobUri);
string text;
using (var memoryStream = new MemoryStream())
{
blockBlob.DownloadToStream(memoryStream);
text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
}
Console.WriteLine(text);
What am I doing wrong? 我究竟做错了什么?
I believe the problem is with the following line of code: 我相信问题在于以下代码行:
CloudBlockBlob blockBlob = container.GetBlockBlobReference(daily.BlobUri);
If you look at GetBlockBlobReference
documentation, the parameter expected is actually blob's name and not the URL. 如果查看
GetBlockBlobReference
文档,预期的参数实际上是blob的名称而不是URL。
Please try changing it to blob's name. 请尝试将其更改为blob的名称。 For testing purpose, please try the following code:
出于测试目的,请尝试以下代码:
CloudBlockBlob blockBlob = container.GetBlockBlobReference("plot1251time2010-01-02t00:00:01z.json");
You should not get an error. 你不应该得到一个错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.