Commit 92c8c88e by qwmqiuwenmin

fix

parent 79abd131
...@@ -122,7 +122,9 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -122,7 +122,9 @@ public class MaterialApiServiceImpl implements MaterialApiService {
url = materialDTO.getLink(); url = materialDTO.getLink();
} }
if(fileType != null){ if(fileType != null){
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url),url.split(".")[1], fileType.getCode()); String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url),arr[count - 1], fileType.getCode());
if(jp.getErrorCode() == 0){ if(jp.getErrorCode() == 0){
materialDTO.setWxLastUploadTime(new Date()); materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString()); materialDTO.setMediaId(jp.getResult().toString());
...@@ -170,7 +172,9 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -170,7 +172,9 @@ public class MaterialApiServiceImpl implements MaterialApiService {
oldUrl = old.getLink(); oldUrl = old.getLink();
} }
if(fileType != null && !url.equals(oldUrl)){ if(fileType != null && !url.equals(oldUrl)){
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url),url.split(".")[1], fileType.getCode()); String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url),arr[count - 1], fileType.getCode());
if(jp.getErrorCode() == 0){ if(jp.getErrorCode() == 0){
materialDTO.setWxLastUploadTime(new Date()); materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString()); materialDTO.setMediaId(jp.getResult().toString());
...@@ -209,7 +213,9 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -209,7 +213,9 @@ public class MaterialApiServiceImpl implements MaterialApiService {
fileType = QywxMediaTypeEnum.FILE; fileType = QywxMediaTypeEnum.FILE;
url = old.getLink(); url = old.getLink();
} }
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url),url.split(".")[1], fileType.getCode()); String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url),arr[count - 1], fileType.getCode());
if(jp.getErrorCode() == 0){ if(jp.getErrorCode() == 0){
old.setWxLastUploadTime(new Date()); old.setWxLastUploadTime(new Date());
old.setMediaId(jp.getResult().toString()); old.setMediaId(jp.getResult().toString());
...@@ -227,8 +233,9 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -227,8 +233,9 @@ public class MaterialApiServiceImpl implements MaterialApiService {
} }
public static void main(String[] args) { public static void main(String[] args) {
String str = "{errcode=0, errmsg=ok, media_id=3ymUzyvUwcIohAXb1lbrL-6Fa-yD3njQpgFCYrEDUHpDaja_ZThd-6XW95NEVjY1l, created_at=1589335350, type=image}"; String str = "https://other-1251519181.cos.ap-shanghai.myqcloud.com/haoban/20200518101933/【④好办-数据】(1)(1).xlsx";
JSON.parseObject(str); int count = str.split("/").length;
System.err.println(str.split("/")[count - 1]);
} }
private static byte[] getFileByte(String url) { private static byte[] getFileByte(String url) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment