如何提供 .RTF

发布于 2024-08-02 23:25:22 字数 478 浏览 5 评论 0原文

我支持一个显示数据库报告的 Web 应用程序。有时,报告会包含附件(通常是也存储在数据库中的图像/文档)。

我们通过动态 .htm 资源提供附件,该资源从数据库流式传输附件,并根据附件类型填充内容类型(我们支持 PDF、RTF 和各种图像格式)

对于 RTF,我们提供了跨越一个问题。似乎许多 Windows 用户默认没有与“application/rtf”内容类型关联(他们确实有与 *.rtf 文件扩展名关联)。因此,在 Internet Explorer 6 中单击附件链接不会执行任何操作。

返回“application/msword”作为内容类型似乎可以使 RTF 在单击链接时可见,但仅适用于具有以下权限的用户:安装了 MS Office(某些用户不会安装此软件,而是使用备用 RTF 阅读器,例如 OpenOffice)。

该应用程序是公开访问的,因此我们无法控制用户的计算机设置。

这里有人之前解决过这个问题吗?又如何呢?谢谢!

I support a web-application that displays reports from a database. Occassionally, a report will contain an attachment (which is typically an image/document which is stored in the database as well).

We serve the attachment via a dynamic .htm resource which streams the attachment from the database, and populates the content-type based on what type of attachment it is (we support PDFs, RTFs, and various image formats)

For RTFs we've come across a problem. It seems a lot of Windows users don't defaultly have an assocation for the 'application/rtf' content-type (they do have an association for the *.rtf file extention). As a result, clicking on the link to the attachment doesn't do anything in Internet Explorer 6.

Returning 'application/msword' as the content-type seems to make the RTF viewable when clicking on the link, but only for people who have MS Office installed (some of the users won't have this installed, and will use alternate RTF readers, like OpenOffice).

This application is accessed publicly, so we don't have control of the user's machine settings.

Has anybody here solved this before? And how? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

香橙ぽ 2024-08-09 23:25:22

使用 application/octet-stream content-type 强制下载。下载后,应该可以在注册来处理 .rtf 文件的任何内容中查看它。

Use application/octet-stream content-type to force download. Once it's downloaded, it should be viewable in whatever is registered to handle .rtf files.

痴情换悲伤 2024-08-09 23:25:22

除了 Content-Type 标头之外,您还需要添加以下内容:

Content-Disposition: attachment; filename=my-document.rtf

In addition to the Content-Type header, you also need to add the following:

Content-Disposition: attachment; filename=my-document.rtf
夏日落 2024-08-09 23:25:22

写字板(几乎每台 Windows 计算机上都有)可以查看 RTF 文件。是否有“应用程序/写字板”内容类型?

或者,考虑到 RTF 文件很少见,最好的解决方案可能是使用服务器端组件打开 RTF 文件,将其转换为其他格式(如 PDF 或纯 HTML),然后将其提供给请求的客户端。我不知道您在服务器端使用什么语言/平台,所以我不知道该告诉您使用什么。

Wordpad (which is on pretty much every Windows machine) can view RTF files. Is there an 'application/wordpad' content-type?

Alternatively, given the rarety of RTF files, your best solution might be to use a server-side component to open the RTF file, convert it to some other format (like PDF or straight HTML), and serve that to the requesting client. I don't know what language/platform you're using on the server side, so I don't know what to tell you to use for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文