C # REST API, файл zur BLOB-файла Azure застрял на 136 КБ и выдает ошибку сети - PullRequest
0 голосов
/ 31 октября 2019

Когда я запускаю код локально, он работает хорошо, но когда я развертываю его в службе приложений Azure, он начинает загружать файл, но остается на 136 КБ, и после долгого времени показывает ошибку сети.

    public HttpResponse downloadFileZip() {
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse('BLOB Connection String');
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobClient.GetContainerReference('Container Name');
        string Path = System.IO.Path.GetTempFileName();

        using (ZipFile zip = new ZipFile())
        {
            foreach (IListBlobItem item in container.ListBlobs('DataFile', true))
            {
                if (item.GetType() == typeof(CloudBlockBlob) || item.GetType() == typeof(CloudAppendBlob))
                {
                    using (MemoryStream stream = new MemoryStream())
                    {
                        CloudBlob blob = (CloudBlob)item;
                        blob.DownloadToStream(stream);
                        zip.AddEntry(blob.Name, stream.ToArray());
                    }

                }
            }

            zip.Save(Path);

            HttpContext.Current.Response.Clear();

            HttpContext.Current.Response.ContentType = "application/zip";
            HttpContext.Current.Response.AddHeader("Content-Length", new FileInfo(Path).Length.ToString());
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
            HttpContext.Current.Response.AddHeader("TransferEncodingChunked", "true");
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=DataFile.zip");

            HttpContext.Current.Response.Flush();

            HttpContext.Current.Response.WriteFile(Path);
            HttpContext.Current.Response.End();

            return HttpContext.Current.Response;
        }
    }
...