python - Azure get_blob 仅返回 4KB 的图像大小

标签 python azure

我使用下面的代码从 blob 存储下载图像,但它只下载 10MB 图片中的 4KB:

  file = blob.get_blob('picture', filename)
            with open(filename, 'w') as f:
                f.write(file)

有人知道为什么会发生这种情况吗?

最佳答案

你需要这样的东西:

        // Retrieve the content of a blob. 
    // Return true on success, false if not found, throw exception on error.

    public string GetBlob(string container, string blob)
    {
        return Retry<string>(delegate()
        {
            HttpWebResponse response;

            string content = null;

            try
            {
                response = CreateRESTRequest("GET", container + "/" + blob).GetResponse() as HttpWebResponse;

                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    content = reader.ReadToEnd();
                }

                response.Close();
                return content;
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError &&
                    ex.Response != null &&
                    (int)(ex.Response as HttpWebResponse).StatusCode == 409)
                    return null;

                throw;
            }
        });
    }

关于python - Azure get_blob 仅返回 4KB 的图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15340020/

相关文章:

c# - 无法连接到 Azure 通知中心

python - 包含反斜杠字符的文档字符串的问题

python - AWS Lambda 未检测到 pyopenssl

python - 使用 Python 日志记录模块时出现重复的日志输出

python - 迭代从 .txt 文件转换的列表时遇到问题

Azure DevOps,特别是管道,而不是发布

python - PandaTables 和 Exif - 根据需要添加列

azure - Windows Azure 服务总线队列重复检测如何工作?

azure - 如何在 KQL 中使用通配符 (*) 作为连接参数?

azure - 如何在 Windows 上更新 azure-cli?