diff --git a/pom.xml b/pom.xml index be6d056b7..57a345101 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.4.20 + 1.4.21 UTF-8 1.8.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java b/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java index 5079ba76b..280863f6d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java +++ b/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java @@ -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");