Ejemplo n.º 1
0
        public void Process(HttpResponse response)
        {
            response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
            response.AppendHeader("ETag", serverFingerprint.ETag);
            response.AppendHeader("Cache-Control", "private, max-age=0");
            if (!string.IsNullOrEmpty(fileName))
            {
                response.AppendHeader(
                    "Content-Disposition",
                    "attachment; filename=\"" + Path.GetFileName(fileName) + "\"");
            }
            if (!string.IsNullOrEmpty(type))
            {
                response.ContentType = type;
            }
            else if (!string.IsNullOrEmpty(fileName))
            {
                var mimeType = GetMimeType(fileName);
                response.ContentType = mimeType;
            }
            else
            {
                response.ContentType = "application/octetstream";
            }

            fileTransfer.Download(response.OutputStream);
        }
        private void downloader_DoWork(object sender, DoWorkEventArgs e)
        {
            int count = 0;

            foreach (PackageDetails package in packages)
            {
                Stream outputStream = File.Create(Path.Combine(downloadLocation, package.Name + ".zip"));
                try
                {
                    IFileTransfer fileTransfer = project.RetrieveFileTransfer(package.FileName);
                    fileTransfer.Download(outputStream);
                }
                finally
                {
                    outputStream.Flush();
                    outputStream.Close();
                }

                downloader.ReportProgress(count++);
            }
        }