Commit 4a80e7b6 authored by fangxinjiang's avatar fangxinjiang

二维码生成

parent 3db2b3db
......@@ -92,20 +92,9 @@ public class FileUploadServiceImpl implements FileUploadService {
if (Common.isEmpty(fileName)) {
return R.failed("文件名不能为空!");
}
if (fileName.length() > 100) {
return R.failed("文件名不能超过100个字符!");
}
//filePath不传默认存储空间的根目录
//jpg,jpeg,png,bmp
String key = "";
if (Common.isNotNull(filePath)) {
key = filePath + "/" + System.currentTimeMillis() + fileName;
} else {
key = System.currentTimeMillis() + fileName;
}
if (!Common.checkFile(key)) {
return R.failed("非法上传类型!");
}
String key = System.currentTimeMillis() + fileName;
boolean flag = ossUtil.uploadFileByStream(fileIn, key, null);
FileVo fileVo;
TAttaInfo attaInfo;
......@@ -171,10 +160,18 @@ public class FileUploadServiceImpl implements FileUploadService {
}
InputStream in = codeUtil.createPng(url);
try {
return this.uploadImg2(in,"mvp_qr",CommonConstants.EIGHT_INT,domainId,name);
return this.uploadImg2(in,"mvp_qr",CommonConstants.EIGHT_INT,domainId,"output_qrcode.png");
} catch (IOException e) {
log.error("获取二维码失败",e);
return R.failed(CommonConstants.RESULT_DATA_FAIL);
}finally{
if (Common.isNotNull(in)){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
\ No newline at end of file
......@@ -61,6 +61,7 @@ public class QrCodeUtil {
File file = new File("output_qrcode.png");
ImageIO.write(image, "PNG", file);
InputStream in = new FileInputStream(file);
file.deleteOnExit();
return in;
} catch (IOException e) {
log.error("failed:生成二维码失败",e.getMessage());
......
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