Exemple #1
0
        private void DownloadMd5(string md5)
        {
            // access must be verified before calling this method (no verification is done here)
            string fullpath = DBFile_Extensions.GetFullPath(md5);

            if (fullpath == null)
            {
                throw new HttpException(404, "Could not find the file.");
            }

            if (fullpath.EndsWith(".gz"))
            {
                string AcceptEncoding = Request.Headers["Accept-Encoding"];
                if (!string.IsNullOrEmpty(AcceptEncoding) && AcceptEncoding.Contains("gzip"))
                {
                    Response.AppendHeader("Content-Encoding", "gzip");
                }
                else
                {
                    // need to decompress this stream...
                    using (Stream str = File.OpenRead(fullpath)) {
                        DownloadStream(str, MimeTypes.GZ);
                    }
                    return;
                }
            }

            Response.AppendHeader("Content-Length", new System.IO.FileInfo(fullpath).Length.ToString());
            Response.TransmitFile(fullpath);
        }
Exemple #2
0
 public Stream Download(DBFile file)
 {
     if (file.file_id.HasValue)
     {
         return(new DBFileStream(file, this));
     }
     else
     {
         return(new System.IO.Compression.GZipStream(new FileStream(DBFile_Extensions.GetFullPath(file.md5), FileMode.Open, FileAccess.Read), System.IO.Compression.CompressionMode.Decompress));
     }
 }