Commit 461974c8 authored by fangxinjiang's avatar fangxinjiang

二维码生成

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