gpt4 book ai didi

c++ - 扩展名为 mime 字符串的文件名

转载 作者:行者123 更新时间:2023-11-28 07:16:07 24 4
gpt4 key购买 nike

我有 mime 作为字符串和 httpheader 如何从 http header 获取带有扩展名的文件名,或者只是有什么方法可以从 mime 获取扩展名?

例如: MIME,扩展名

 `application/octet-stream  class`
`application/octet-stream dms`
` application/octet-stream exe`
`application/octet-stream lha`

上面的 mime 字符串相同但扩展名不同

这些是我从压缩文件的 httpHeader 得到的东西

Keep-Alive : timeout=10

Connection : Keep-Alive

Age : 4418

Accept-Ranges : bytes

ETag : "ee0043-157f-4acf6ff5c1640"

Cache-Control : max-age=10800, s-maxage=10800

x-mii-cache-hit : 1

X-Pb-Mii : Powered by Mirror Image Internet

Via : 1.1 sjc005158 (MII-APC/2.3), 1.1 sjc005112 (MII-APC/2.3)

Content-Length : 5503

Last-Modified : Thu, 15 Sep 2011 08:52:33 GMT

Date : Tue, 26 Nov 2013 08:30:27 GMT

Content-Type : application/zip

Server : MII-APC/2.4.5

最佳答案

如果你真的想使用像 this 这样的列表,我想你可以但也许这不是最好的方法。

另一种方法是使用 Content Disposition header (如果可用):

    Content-Disposition: attachment; filename=Myfile.txt

然后从那里解析文件名和扩展名

关于c++ - 扩展名为 mime 字符串的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20213866/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com