postman postman Content-disposition 下载
时间: 2023-08-19 17:09:57 浏览: 67
在Postman中,当使用Content-Disposition头部来下载文件时,如果文件名包含中文字符,可能会出现问题。解决这个问题的方法是使用encodeURIComponent对文件名进行编码,然后将编码后的文件名作为参数传递给Content-Disposition头部的filename字段。这样可以避免下载中文文件名时出现问题。例如,将第二段代码改为第一段代码即可解决问题:
'Content-Disposition': 'attachment; filename=' + encodeURIComponent(fileName)
如果前端使用iframe进行下载,下载下来的文件将是正常的文件,并且文件名也可以是中文。如果需要在前端获取文件名,可以使用decodeURIComponent进行解码。通过解析编码后的文件名,就可以获取到正常的文件名了。
#### 引用[.reference_title]
- *1* [解决node.js报错Invalid character in header content [“Content-Disposition“]](https://blog.csdn.net/tangdou369098655/article/details/117847591)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v4^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)