首页 文章

Azure blob存储返回404一些文件

提问于
浏览
0

我有一个Azure blob存储设置,里面有几个文件 . 我可以在文件较小(KB大小)时将文件下载到Stream中,但是当文件稍大(MB大小)时,我会收到404错误 . 我已经从门户网站手动下载了一个返回404的图像并调整了该图像的大小,然后将较小的图像上传回容器,然后我可以将其语法下载到流中 .

这是我用来下载blob的代码

private static byte[] PerformDownload(string fileName, CloudBlobContainer container)
        {
            var blockBlob = container.GetBlockBlobReference(fileName);
            using (var memoryStream = new MemoryStream())
            {
                blockBlob.DownloadToStream(memoryStream);
                memoryStream.Seek(0, SeekOrigin.Begin);

                var binaryReader = new BinaryReader(memoryStream);
                var bytes = binaryReader.ReadBytes((int)memoryStream.Length);
                return bytes;
            }
        }

容器被传递到这个方法,正如我所提到的,我可以从容器中下载一些文件而没有问题,但是如果你需要那些代码我也可以添加它

使用您找到的标准示例检索容器,但这是代码

private static CloudBlobContainer GetContainer(string containerName)
        {
            var storageAccount = CloudStorageAccount.Parse(ConnectionString);

            var container = CreateContainerIfNeeded(storageAccount, containerName);
            return container;
        }

        private static CloudBlobContainer CreateContainerIfNeeded(CloudStorageAccount storageAccount, string containerName)
        {
            var blobClient = storageAccount.CreateCloudBlobClient();

            var container = blobClient.GetContainerReference(containerName);

            container.CreateIfNotExists();

            return container;
        }

案例敏感性也不是问题,因为容器的名称是2017-106,文件是4448.jpg .

1 回答

  • 0

    我可以在文件很小(KB大小)时将文件下载到Stream中,但是当文件稍大(MB大小)时,我会收到404错误 .

    目前max size of a block blob约 . 4.75 TB,将MB大小的数据存储在块blob中,当您访问blob时,不应导致Azure Blob服务返回404 . 404 error表示指定的blob不存在,正如Gaurav Mantri所说,Blob name is case-sensitive,请确保您提供的 filename (blob名称)确实存在于您的容器中 .

    此外,如果只找到该特定blob,但它确实存在于您的容器中,则可以创建支持请求来报告它 .

相关问题