我使用下面的代码从 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/