Commit 411110ae by 徐高华

Merge branch 'master_118' into 'developer'

朋友圈图片url

See merge request !888
parents 94bca34b 694a1b98
......@@ -207,13 +207,23 @@ public class MaterialServiceImpl implements MaterialService {
if(from == 2) {
url = entity.getImgUrl() ;
}
String[] arr = url.split("/");
String[] arr = null ;
if(url.contains("?")) {
arr = url.split("?")[0].split("/") ;
}else {
arr = url.split("/");
}
int count = arr.length;
if(from==2) {
// 朋友圈上传接口
if (type == 2) {
url+= "?imageView2/2/w/1440/h/1080" ;
if(url.contains("?")) {
}else {
url+= "?imageView2/2/w/1440/h/1080" ;
}
}
logger.info("url={}",url);
jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
}else {
// 群发上传
......
package com.gic.haoban.manage.service.util;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import java.io.InputStream;
import java.net.URL;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Created 2021/4/16.
*
* @author hua
*/
public class CommonUtil {
private static final Logger logger = getLogger(CommonUtil.class);
/**
* 获取字符串
*
* @param url
* @return
*/
public static byte[] getFileByte(String url) {
try (InputStream in = new URL(url).openStream()) {
return IOUtils.toByteArray(in);
} catch (Exception e) {
logger.info("【异常】" + e.getMessage(), e);
}
return null;
}
}
package com.gic.haoban.manage.service.util;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import java.io.InputStream;
import java.net.URL;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Created 2021/4/16.
*
* @author hua
*/
public class CommonUtil {
private static final Logger logger = getLogger(CommonUtil.class);
/**
* 获取字符串
*
* @param url
* @return
*/
public static byte[] getFileByte(String url) {
try (InputStream in = new URL(url).openStream()) {
return IOUtils.toByteArray(in);
} catch (Exception e) {
logger.info("【异常】{} ,{},{}" , e.getMessage(), e , url);
}
return null;
}
public static void main(String[] args) {
getFileByte("https://jhdm-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-cce7cc3de0bf48cebf16fb5c65f4ae9c.jpg?imageView2/format/jpg/q/50?imageView2/2/w/1440/h/1080") ;
System.out.println(1);
}
}
\ No newline at end of file
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