【问题标题】:Mime-type .tif/pdf files are corrupted and will not open .NET V2.0Mime 类型的 .tif/pdf 文件已损坏,无法打开 .NET V2.0
【发布时间】:2013-12-20 04:01:12
【问题描述】:

Web 系统(完全相同的站点)已迁移到新服务器。 mime 类型的 tif 文件附件在以前的生产服务器上工作,并且没有更改任何代码,但由于迁移我们无法专门打开 .tif 文件。 PDF 文件在浏览器中旋转到空白页面。

代码调用 web 服务(工作正常)从 JDE 环境中获取缓存文档

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

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

返回 mime 类型没有问题,即“图像/tiff”。已在服务器级别设置设置以接受 MIME-TYPE 属性中的 .tif 和 .tiff。

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();

这段代码是在生产环境中工作的原始代码,现在由于对象引用错误而出错。

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

但是,当我将 .mime 扩展名添加到 tempFile 时,它​​不再出错并获取 byteRange。

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

出现对话框 - 下载文件 - 但打开时显示空白或错误​​提示文件似乎已损坏、损坏或太大。我尝试以其他几种格式打开,但无济于事。 .tif 文件会发生这种情况。 PDF 只是在浏览器中留下一个空白页面,没有选项下载对话框。

这是在生产中工作的相同代码,是一个 .NET V2 应用程序。任何建议将不胜感激。

【问题讨论】:

    标签: c# .net-2.0 mime tiff corruption


    【解决方案1】:

    这已解决,这是一个缓存问题。我们重新编写了破坏标头的 Get CacheDocument 方法。现在它是一个 GetDocument 方法,我们现在可以抓取文档并加载它们。问题出在代码上,奇怪的是它在以前的生产中仍然有效。

    【讨论】:

      猜你喜欢
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      • 2020-12-16
      • 1970-01-01
      • 2021-05-18
      相关资源
      最近更新 更多