是否可以从http标头中找到文件名

编程入门 行业动态 更新时间:2024-10-22 08:42:36
本文介绍了是否可以从http标头中找到文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

通常在下载文件时,假设使用QNetworkAccessManager,链接末尾不存在文件名。在这种情况下如何获得正确的文件名。即使链接不包含名称提示,firefox也会始终使用其正确的名称和扩展名下载该文件。我们可以使用mime-types获得一些扩展,但是文件名是什么。

Usually when downloading files, suppose using QNetworkAccessManager, the filename is not present at the end of link. How to get proper file names in that case. Even if link doesn't contain a hint of name, firefox always downloads the file with its proper name and extension. We can get a hint of extention using mime-types but what about file names.

推荐答案

是的。这是 Content-Disposition:附件; filename =< file name.ext> 标头。有一个强烈建议将内容类型设置为 application / octet-stream ,因此浏览器及其插件不会试图打开它。

Yes. It's the Content-Disposition: attachment; filename=<file name.ext> header. There's a strong suggestion to set the content type to application/octet-stream so browsers and their plugins are not tempted to open it instead.

更多推荐

是否可以从http标头中找到文件名

本文发布于:2023-10-31 18:56:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件名   中找到   http

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!