Commit 9e217241 authored by tangtuo's avatar tangtuo

解决文件空格的问题

parent db6549e4
......@@ -69,6 +69,7 @@ public class CopyrightLister {
public void listerCopyrightApply(String serial_code, Message message, Channel channel) throws IOException {
log.info("监听者接收消息, 流水号为: {}", serial_code);
long deliveryTag = message.getMessageProperties().getDeliveryTag();
try {
CopyrightQueryRequest request = new CopyrightQueryRequest(serial_code, copyrightProperties.getAppId());
TreeMap<String, String> map = this.beanToMap(request, copyrightProperties.getAppSecret());
String sign = CopyrightSignUtil.generateSign(map);
......@@ -99,7 +100,6 @@ public class CopyrightLister {
log.error("接口响应失败, 失败原因:{}", copyrightResponse.getMessage());
return;
}
try {
CopyrightApply copyrightApply = copyrightApplyService.getBySerialNum(serial_code);
// if (copyrightApply == null) {
// log.error("unknown serial_code: {}", serial_code);
......@@ -149,7 +149,6 @@ public class CopyrightLister {
copyrightApplyService.updateById(copyrightApply);
} catch (Exception e) {
// 如果上链失败或者更新状态失败, 那么就把消息重新丢入延时队列,稍后重试
rabbitTemplate.convertAndSend(RabbitMQConfig.COPYRIGHT_DIRECT, "copyright.apply", serial_code);
log.error(e.getMessage(), e);
} finally {
......@@ -159,7 +158,6 @@ public class CopyrightLister {
}
private TreeMap<String, String> beanToMap(CopyrightQueryRequest request, String app_secret) {
TreeMap<String, String> map = JSONUtil.toBean(JSONUtil.toJsonStr(request), new TypeReference<TreeMap<String, String>>() {
}, true);
......@@ -197,4 +195,9 @@ public class CopyrightLister {
}
public static void main(String[] args) {
String str = "https://filmchain-file.obs.cn-east-3.myhuaweicloud.com/5f7d224aab0c4c22ae77aa2a21a0787c/权利取得方式证明材料附件 (7).docx";
String s = str.replaceAll(" ", "");
System.out.println(s.equals(str));
}
}
......@@ -47,5 +47,6 @@ public class CopyrightFile {
public CopyrightFile(CopyrightDTO.File file) {
BeanUtil.copyProperties(file, this, true);
this.fileName = file.getFileName().replaceAll(" ", "");
}
}
......@@ -45,7 +45,7 @@ public class ObsUtil {
* @return
*/
public String putObject(MultipartFile file) throws IOException {
String objectName = IdUtil.simpleUUID().concat("/").concat(file.getOriginalFilename());
String objectName = IdUtil.simpleUUID().concat("/").concat(file.getOriginalFilename().replaceAll(" ", ""));
obsClient.putObject(obsProperties.getBucket(), objectName, file.getInputStream());
return String.format("https://%s.%s/%s", obsProperties.getBucket(), obsProperties.getEndPoint(), objectName);
}
......
......@@ -43,7 +43,6 @@ public class CopyrightFileController {
if (!FileSuffix.validFileType(fileSuffix)) {
throw GlobalException.newException(ResultCode.FILE_UPLOAD_ERROR, "不支持当前上传的文件类型");
}
String url = obsUtil.putObject(file);
return ResponseModel.success(url);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment