Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Azure get_blob仅返回4KB的图像大小_Python_Azure - Fatal编程技术网

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

Python Azure get_blob仅返回4KB的图像大小,python,azure,Python,Azure,我使用下面的代码从blob存储下载图像,但它只下载4KB的10MB图片: file = blob.get_blob('picture', filename) with open(filename, 'w') as f: f.write(file) 有人知道为什么会发生这种情况吗?你需要这样的东西: // Retrieve the content of a blob. // Return true on suc

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

  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;
            }
        });
    }
//检索blob的内容。
//成功时返回true,未找到时返回false,出错时抛出异常。
公共字符串GetBlob(字符串容器,字符串blob)
{
返回重试(委托()
{
HttpWebResponse;
字符串内容=null;
尝试
{
response=CreateRESTRequest(“GET”,container+“/”+blob).GetResponse()作为HttpWebResponse;
使用(StreamReader=newstreamreader(response.GetResponseStream())
{
content=reader.ReadToEnd();
}
response.Close();
返回内容;
}
捕获(WebException ex)
{
if(ex.Status==WebExceptionStatus.ProtocolError&&
例如响应!=null&&
(int)(例如作为HttpWebResponse的响应)。状态代码==409)
返回null;
投掷;
}
});
}

您是否在REST API之上编写自己的代码?如果是,请分享完整的代码好吗?在我看来,调用只是首先返回标题,但是您需要在后续标题中指定总页面,以便从blob下载所有页面。不,我使用的是Microsoft Azure提供的python SDK。我使用的是来自的示例