提交 b9646ae7 编写于 作者: 小柒2012

阿里云存储说明

上级 28a581bd
......@@ -30,11 +30,6 @@ public class GirlServiceImpl implements GirlService {
@Value("${ali-yun.oss.url}")
private String ossUrl;
private static int corePoolSize = Runtime.getRuntime().availableProcessors();
private static ThreadPoolExecutor executor =
new ThreadPoolExecutor(corePoolSize, corePoolSize+1, 10l, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(100));
@Override
public Result list(Integer pageSize, Integer pageNo) {
String nativeSql = "SELECT * FROM app_girl WHERE status=? GROUP BY id DESC ";
......@@ -47,11 +42,12 @@ public class GirlServiceImpl implements GirlService {
@Override
@Transactional(rollbackFor=Exception.class)
public void upload(Girl image, File toPic,File fromPic) {
Runnable task = () -> {
String picName = image.getOssUrl().replace("zoom_","");
aliYunUtils.upload(fromPic,picName);
};
executor.execute(task);
/**
* 不需要阿里云OSS注释掉就可以
* 缩放、正常
*/
String picName = image.getOssUrl().replace("zoom_","");
aliYunUtils.upload(fromPic,picName);
aliYunUtils.upload(toPic,image.getOssUrl());
image.setOssUrl(ossUrl+"/"+image.getOssUrl());
dynamicQuery.save(image);
......
......@@ -75,6 +75,10 @@ public class GirlController {
image.setGmtCreate(DateUtils.getTimestamp());
image.setStatus(Short.parseShort(status));
meiZiService.upload(image,toPic,fromPic);
/**
* 默认返回的是阿里云OSS地址
* 如果不需要改成本地的就可以
*/
res.put("url",ossUrl+"/"+fileDay+"/"+fileName);
res.put("success", 1);
res.put("message", "upload success!");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册