[英]How to upload a file which name contains special characters using JMeter?
I struggle to upload files using a POST HTTP request in JMeter, which file name (not file content) contains special characters such as "é è à".我很难使用 JMeter 中的 POST HTTP 请求上传文件,文件名(不是文件内容)包含特殊字符,例如“é è à”。 For example: "nameWithSpecialCharacters_éè.txt".例如:“nameWithSpecialCharacters_éè.txt”。
Is this a limitation of JMeter?这是JMeter的限制吗? I'm on 5.5 version (latest as of now).我使用的是 5.5 版本(目前最新)。
Thank you for your help.谢谢您的帮助。
I tried several things such as putting file.encoding=UTF-8 in JMeter settings.我尝试了几件事,例如将 file.encoding=UTF-8 放入 JMeter 设置中。 I also put UTF-8 in "Content encoding" in HTTP Request sampler but none of these work... I have the same issue if I use BeanShell PreProcessor and set the files to upload with sampler.setHTTPFiles(filesToUpload)我还将 UTF-8 放入 HTTP 请求采样器的“内容编码”中,但这些都不起作用...如果我使用 BeanShell PreProcessor 并将文件设置为使用 sampler.setHTTPFiles(filesToUpload) 上传,我会遇到同样的问题
No matter what I do the characters are replaced by "?"无论我做什么,字符都会被替换为“?” in the body of the request:在请求正文中:
Content-Disposition: form-data; Content-Disposition:表单数据; name="file 1";名称=“文件1”; filename="nameWithSpecialCharacters _??.txt" Content-Type: text/plain Content-Transfer-Encoding: binary filename="nameWithSpecialCharacters _??.txt" 内容类型:文本/纯文本 内容传输编码:二进制
It looks like a bug in the HttpClient4 implementation , I would suggest raising it via JMeter Issues它看起来像是HttpClient4 实现中的错误,我建议通过JMeter Issues提出它
In the meantime as a workaround you could switch your HTTP Request sampler to use Java
as the implementation:同时,作为解决方法,您可以将 HTTP 请求采样器切换为使用Java
作为实现:
If you have more than one HTTP Request sampler you could use HTTP Request Defaults to perform the change in one place for all.如果您有多个 HTTP Request 采样器,您可以使用HTTP Request Defaults在一个地方为所有采样器执行更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.