fix(bug): 修复又拍云文件中包含特殊字符时,调用 upyun 接口未进行 url encode 返回 400,影响又拍云单文件直链无法使用。

This commit is contained in:
zhaojun
2022-04-02 18:26:32 +08:00
parent 168b0b08f3
commit e09c6b4e58

View File

@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -121,7 +122,7 @@ public class UpYunServiceImpl extends AbstractBaseFileService implements BaseFil
int lastDelimiterIndex = path.lastIndexOf("/");
String name = path.substring(lastDelimiterIndex + 1);
Map<String, String> fileInfo = upYun.getFileInfo(StringUtils.removeDuplicateSeparator(basePath + ZFileConstant.PATH_SEPARATOR + path));
Map<String, String> fileInfo = upYun.getFileInfo(URLUtil.encode(StringUtils.removeDuplicateSeparator(basePath + ZFileConstant.PATH_SEPARATOR + path), StandardCharsets.UTF_8));
if (fileInfo == null) {
throw new NotExistFileException();