1

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

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

有谁知道为什么会这样?

4

1 回答 1

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;
            }
        });
    }
于 2013-03-11T18:39:16.703 回答