优化gateway 上传文件报错

master
luoyang 5 years ago
parent 61c6d63508
commit 39d3837e9c

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.4.20</version>
<version>1.4.21</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -5,7 +5,10 @@ import au.com.royalpay.payment.core.utils.PaymentValidUtils;
import au.com.royalpay.payment.manage.gateway.advice.Gtw2Ctrl;
import au.com.royalpay.payment.manage.gateway.core.GatewayMerchantApply;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -19,6 +22,7 @@ import javax.annotation.Resource;
@RequestMapping("/api/v1.0/org_gateway/partners/{shortId}")
@Gtw2Ctrl
public class GtwPayController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private GatewayMerchantApply gatewayMerchantApply;
@Resource
@ -41,12 +45,18 @@ public class GtwPayController {
}
@PostMapping("/attachment/files")
public JSONObject uploadFile(@PathVariable String shortId,@RequestParam MultipartFile file) throws Exception {
public JSONObject uploadFile(@PathVariable String shortId,@RequestParam MultipartFile file) {
JSONObject org = gatewayMerchantApply.validOrgV200(shortId);
if (org == null) {
throw new InvalidShortIdException();
}
JSONObject fileInfo = attachmentClient.uploadFile(file, false);
JSONObject fileInfo = new JSONObject();
try {
fileInfo = attachmentClient.uploadFile(file, false);
} catch (Exception e) {
logger.error("file upload fail :{}" , e.getMessage());
throw new BadRequestException("File upload failed");
}
fileInfo.put("file_type", fileInfo.getString("filetype"));
fileInfo.remove("filepath");
fileInfo.remove("length");

Loading…
Cancel
Save