Browse Source

1.文件上传 部分修改

dev
ldj 8 months ago
parent
commit
f9f6db4b96
2 changed files with 8 additions and 7 deletions
  1. +6
    -6
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressImageController.java
  2. +2
    -1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/dto/photobank/PhotoBankUploadImageDTO.java

+ 6
- 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressImageController.java View File

@@ -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();


+ 2
- 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/dto/photobank/PhotoBankUploadImageDTO.java View File

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

Loading…
Cancel
Save