Tech Off Post

Single Post Permalink

View Thread: File Cache/Storage dilemna
  • User profile image

    Thanks for the reply. I agree the FS/Meta in SQL is probably the best, and for reasons you outline specifically holding up the SQL resource for the download. But I find that really isn't as much of the problem as is the stream to the client. Performance aside I am finding that PDF files actually "request" twice? Here is the handler I built to accomodate file extensions and for PDF and SWF files, I am showing two hits to this handler?

    public void ProcessRequest(HttpContext context)
    HttpResponse response = context.Response;
    string fileName = context.Request.QueryString["FileName"].ToString();
    if(fileName.IndexOf(".doc") > 0) response.ContentType = "application/msword";
    if(fileName.IndexOf(".pdf") > 0) response.ContentType = "application/pdf";
    if(fileName.IndexOf(".jpg") > 0) response.ContentType = "image/jpeg";
    if(fileName.IndexOf(".gif") > 0) response.ContentType = "image/gif";
    if(fileName.IndexOf(".swf") > 0) response.ContentType = "application/x-shockwave-flash";
    if(fileName.IndexOf(".xls") > 0) response.ContentType = "application/";
    DateTime start = DateTime.Now;
    System.IO.FileStream file = new System.IO.FileStream(fileName, System.IO.FileMode.Open);;
    long bytesize = file.Length;
    byte[] buffer = new byte[(int)bytesize];
    file.Read(buffer, 0, (int)bytesize);
    DateTime end = DateTime.Now;
    FileCaching.FileCache fileCache = new FileCacheing.FileCaching.FileCache();


    So now I have two hits to the FS? Is there something I am missing here? (Disregard the FileCaching it's only stubbed out right now).