Ruby Sinatra 附件
我有一个 sinatra 应用程序,当用户单击文件时,它会向用户发送一个文件,我不想提供扩展名,但 Sinatra 或浏览器给它“test.html”,
attachment("test")
response.write("write test data")
我怎样才能给出 test 的文件名给用户,而不将其重命名为 test.html
I have a sinatra application that sends a file to the user when they click a file, I don't want to give an extension, but Sinatra or the browser is giving it "test.html"
attachment("test")
response.write("write test data")
how can I give the file name of test to the user without it getting renamed to test.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Sinatra 传递给浏览器的 MIME 类型,这可能是浏览器正在执行的操作。
如今,扩展在 Windows、Mac OS 和 Linux 操作系统上非常重要,因此该价值对用户及其计算机的操作系统很有帮助。也许您可以通过提供有关所发送内容的实际类型的提示来改进事情。
Sinatra 的“MIME 类型”文档说道:
It might be something the browser is doing, based on the MIME type being passed to it by Sinatra.
Extensions are significant on Windows, Mac OS and Linux OSes these days, so that value is helpful for the user and their machine's OS. Maybe you can improve things by providing a hint about the actual type of content being sent.
Sinatra's "MIME Types" documentation says: