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; }