我使用下面的代码从blob存储下载图像,但它只下载4KB的10MB图片:
file = blob.get_blob('picture', filename)
with open(filename, 'w') as f:
f.write(file)
任何人都知道为什么会这样?
答案 0 :(得分:0)
您需要以下内容:
// 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;
}
});
}