When an object name contains Chinese characters, the browser or HTTP client cannot interpret the raw characters in a URL, causing garbled output when you preview or download the object. You must URL-encode the Chinese characters before using them in a URL.
For example, the object 测试.txt must be referenced in a URL as %E6%B5%8B%E8%AF%95.txt.
Preserve the original filename when downloading
URL encoding lets you access the object, but the downloaded file may still be saved with a garbled filename. To keep the original Chinese filename on the local computer, set the Content-Disposition response header on the object using this format:
attachment;filename=%E6%B5%8B%E8%AF%95.txt;filename*=UTF-8''%E6%B5%8B%E8%AF%95.txtThe filename parameter provides a fallback for older clients. The filename* parameter (RFC 5987) carries the UTF-8-encoded name and takes precedence in modern browsers.
To construct this header value in Java:
"attachment;filename=" + URLEncoder.encode("测试", "UTF-8") + ".txt;filename*=UTF-8''" + URLEncoder.encode("测试", "UTF-8") + ".txt"For instructions on setting the Content-Disposition header, see Manage object metadata.