Mime-type .tif/pdf files are corrupted and will not open .NET V2.0

517 views Asked by At

Web systems (exact same site) has been migrated to new servers. The mime-type tif file attachments worked on the previous servers in production and no code has been changed, but since the migration we cannot open specifically, .tif file. PDF files spin to a blank page in the browser.

The code calls a webservice(which works fine) to get a Cache Document from a JDE environment

object[] file = docA.CacheDocument("/" + path, filename, doctype, xxx.Global.JDEEnvironment);

fileSize = (int)file[0];
mimeType = (string)file[1];

There is no issue returning the mime-type, which is a "image/tiff". Settings have been set on the server level to accept both .tif and .tiff in MIME-TYPE properties.

HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = mimeType;

string tempPath = "/" + path;
string tempFile = filename;


int i = 0;
while (i < fileSize)
{
    int[] byteRangeAry = new int[2];
    byteRangeAry[0] = i;
    if ((i + _chunkSize) < fileSize)
    {
        byteRangeAry[1] = i + _chunkSize;
    }
    else
    {
        byteRangeAry[1] = fileSize;
    }

    var docdata = docA.GetByteRange(tempPath, tempFile, byteRangeAry);
    HttpContext.Current.Response.BinaryWrite(docdata);
    HttpContext.Current.Response.Flush();

    //Move the index to the next chunk
    i = byteRangeAry[1] + 1;
}

HttpContext.Current.Response.Flush();

this snipit is untouched code that worked in production and now errors out with an object reference error.

var docdata = docA.GetByteRange(tempPath, tempFile, byteRangeAry);

However when I add a .mime extention to the tempFile, it no longer errors out and gets the byteRange.

var docdata = docA.GetByteRange(tempPath, tempFile + ".mime", byteRangeAry);

The dialog box appears - downloads the file - but opens to a blank or an error saying the file appears to be damages, corrupted or is too large. I have tried opening in several other formats to no avail. This happens with the .tif file. The PDF just leaves a blank page in the brower without an option download dialog box.

This is the same code that worked in production and is a .NET V2 app. Any suggestions would be much appreciated.

1

There are 1 answers

0
Ter12345 On

This was resolved, it was a cacheing issue. We re-wrote the Get CacheDocument method that was corrupting the header. Now its a GetDocument method and we are now able to grab documents, and load them. The problem was the code, it is still strange that it worked in the previous production.