From f9f6db4b96fb57a03e8edaf3a9758e737587fa49 Mon Sep 17 00:00:00 2001 From: ldj <1223042416@qq.com> Date: Tue, 5 Mar 2024 09:46:05 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=20=20?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aliexpress/AliexpressImageController.java | 12 ++++++------ .../dto/photobank/PhotoBankUploadImageDTO.java | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressImageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressImageController.java index 5ff3110..6950e4d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressImageController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressImageController.java @@ -117,7 +117,7 @@ public class AliexpressImageController { IopClient client = new IopClientImpl(AliexpressAuthClientConfig.getUrl(), AliexpressAuthClientConfig.getAppKey(), AliexpressAuthClientConfig.getAppSecret()); IopRequest request = new IopRequest(); request.setApiName(AliexpressImageEnu.UPLOAD_IMAGE.getApiName()); - request.addApiParameter("file_name", reqDto.getFile_name()); + request.addApiParameter("file_name", reqDto.getSrc_file_name()); request.addApiParameter("group_id", reqDto.getGroup_id()); try { request.addFileParameter("image_bytes", new FileItem(file.getOriginalFilename(), file.getInputStream(), file.getContentType())); @@ -145,16 +145,16 @@ public class AliexpressImageController { @Log(title = "上传图片到图片银行(推荐使用)", businessType = BusinessType.SELECT) @ApiOperation("上传图片到图片银行(推荐使用)") @PostMapping("/uploadImageForSdk") - public String uploadImageForSdk(@RequestParam("file") MultipartFile file, @RequestBody PhotoBankUploadImageDTO reqDto) throws ApiException { + public String uploadImageForSdk(@RequestBody PhotoBankUploadImageDTO reqDto) throws ApiException { IopClient client = new IopClientImpl(AliexpressAuthClientConfig.getUrl(), AliexpressAuthClientConfig.getAppKey(), AliexpressAuthClientConfig.getAppSecret()); IopRequest request = new IopRequest(); request.setApiName(AliexpressImageEnu.UPLOAD_IMAGE_FOR_SDK.getApiName()); - request.addApiParameter("file_name", reqDto.getFile_name()); + request.addApiParameter("file_name", reqDto.getSrc_file_name()); request.addApiParameter("group_id", reqDto.getGroup_id()); try { - request.addFileParameter("image_bytes", new FileItem(file.getOriginalFilename(), file.getInputStream(), file.getContentType())); - } catch (IOException e) { - return "文件上传失败,IO异常!"; + request.addFileParameter("image_bytes", new FileItem(reqDto.getSrc_file_name(),reqDto.getFile_data())); + } catch (Exception e) { + return "文件上传失败!"; } IopResponse response = client.execute(request, reqDto.getAccessToken(), Protocol.TOP); return response.getGopResponseBody(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/dto/photobank/PhotoBankUploadImageDTO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/dto/photobank/PhotoBankUploadImageDTO.java index c0e34e6..926c2d6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/dto/photobank/PhotoBankUploadImageDTO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/dto/photobank/PhotoBankUploadImageDTO.java @@ -13,8 +13,9 @@ import lombok.Setter; @Getter @Setter public class PhotoBankUploadImageDTO extends AliexpressAuth { + private byte[] file_data; //request.addApiParameter("file_name", "0"); - private String file_name; + private String src_file_name; //request.addApiParameter("group_id", "0"); private String group_id; }