|
@@ -141,7 +141,7 @@ public class CollectApi {
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
- File srcFile = new File("/Users/king/stmms-ms/static/images/6/SM/1/1901040150.jpg"); //初始文件
|
|
|
|
|
|
+ File srcFile = new File("/Users/king/stmms-ms/static/images/1/SM/1/1901130045.jpg"); //初始文件
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传原图(图片加密)
|
|
* 上传原图(图片加密)
|
|
@@ -179,7 +179,7 @@ public class CollectApi {
|
|
File sheetFile = new File(sheetDir + File.separator + imageMd5 + ".jpg");
|
|
File sheetFile = new File(sheetDir + File.separator + imageMd5 + ".jpg");
|
|
LOGGER.info("sheet存放目录:{}", sheetFile.getPath());
|
|
LOGGER.info("sheet存放目录:{}", sheetFile.getPath());
|
|
outputStream = new FileOutputStream(sheetFile);
|
|
outputStream = new FileOutputStream(sheetFile);
|
|
- writeStream(inputStream, outputStream);
|
|
|
|
|
|
+ SystemConstant.writeStream(inputStream, outputStream);
|
|
long end = System.currentTimeMillis();
|
|
long end = System.currentTimeMillis();
|
|
LOGGER.info("生成原图耗时:{}", (end - start) / 1000 + "s");
|
|
LOGGER.info("生成原图耗时:{}", (end - start) / 1000 + "s");
|
|
|
|
|
|
@@ -241,8 +241,8 @@ public class CollectApi {
|
|
outputStream = new FileOutputStream(imageFile);
|
|
outputStream = new FileOutputStream(imageFile);
|
|
outputStreamTemp = new FileOutputStream(imageFileTemp);
|
|
outputStreamTemp = new FileOutputStream(imageFileTemp);
|
|
int index = 0;
|
|
int index = 0;
|
|
- byte[] bytes = new byte[1024];
|
|
|
|
- byte[] bytesEnc = new byte[1024];
|
|
|
|
|
|
+ byte[] bytes = new byte[1024 * 8];
|
|
|
|
+ byte[] bytesEnc = new byte[1024 * 8];
|
|
while ((index = inputStream.read(bytes)) != -1) {
|
|
while ((index = inputStream.read(bytes)) != -1) {
|
|
//将字节数组的数据全部写入到输出流中
|
|
//将字节数组的数据全部写入到输出流中
|
|
for (int i = 0; i < index; i++) {
|
|
for (int i = 0; i < index; i++) {
|
|
@@ -269,7 +269,7 @@ public class CollectApi {
|
|
// outputStreamTemp = new FileOutputStream(thumbFileTemp);
|
|
// outputStreamTemp = new FileOutputStream(thumbFileTemp);
|
|
// ImageIO.write(bufferedImage, "jpg", outputStreamTemp);
|
|
// ImageIO.write(bufferedImage, "jpg", outputStreamTemp);
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
- ImageIO.write(bufferedImage, "gif", os);
|
|
|
|
|
|
+ ImageIO.write(bufferedImage, "jpg", os);
|
|
inputStream = new ByteArrayInputStream(os.toByteArray());
|
|
inputStream = new ByteArrayInputStream(os.toByteArray());
|
|
|
|
|
|
//原图删除
|
|
//原图删除
|
|
@@ -277,7 +277,7 @@ public class CollectApi {
|
|
// inputStream = PictureUtil.getInput(thumbFileTemp);
|
|
// inputStream = PictureUtil.getInput(thumbFileTemp);
|
|
//缩略图删除
|
|
//缩略图删除
|
|
// thumbFileTemp.delete();
|
|
// thumbFileTemp.delete();
|
|
- writeStream(inputStream, outputStream);
|
|
|
|
|
|
+ SystemConstant.writeStream(inputStream, outputStream);
|
|
long end = System.currentTimeMillis();
|
|
long end = System.currentTimeMillis();
|
|
LOGGER.info("生成原图和缩略图耗时:{}", (end - start) / 1000 + "s");
|
|
LOGGER.info("生成原图和缩略图耗时:{}", (end - start) / 1000 + "s");
|
|
|
|
|
|
@@ -355,7 +355,7 @@ public class CollectApi {
|
|
//读取指定路径下面的文件
|
|
//读取指定路径下面的文件
|
|
inputStream = new FileInputStream(file);
|
|
inputStream = new FileInputStream(file);
|
|
outputStream = new BufferedOutputStream(response.getOutputStream());
|
|
outputStream = new BufferedOutputStream(response.getOutputStream());
|
|
- writeStream(inputStream, outputStream);
|
|
|
|
|
|
+ SystemConstant.writeStream(inputStream, outputStream);
|
|
long end = System.currentTimeMillis();
|
|
long end = System.currentTimeMillis();
|
|
LOGGER.info("读取图片耗时:{}", (end - start) / 1000 + "s");
|
|
LOGGER.info("读取图片耗时:{}", (end - start) / 1000 + "s");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -471,27 +471,4 @@ public class CollectApi {
|
|
markSubjectRepo.save(markSubject);
|
|
markSubjectRepo.save(markSubject);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 流写入
|
|
|
|
- *
|
|
|
|
- * @param inputStream
|
|
|
|
- * @param outputStream
|
|
|
|
- * @return
|
|
|
|
- * @throws IOException
|
|
|
|
- */
|
|
|
|
- public OutputStream writeStream(InputStream inputStream, OutputStream outputStream) throws IOException {
|
|
|
|
- int index = 0;
|
|
|
|
- byte[] bytes = new byte[1024];
|
|
|
|
- byte[] bytesEnc = new byte[1024];
|
|
|
|
- while ((index = inputStream.read(bytes)) != -1) {
|
|
|
|
- //将字节数组的数据全部写入到输出流中
|
|
|
|
- for (int i = 0; i < index; i++) {
|
|
|
|
- //通过异或运算加密
|
|
|
|
- bytesEnc[i] = (byte) (bytes[i] ^ SystemConstant.SECRET_KEY);
|
|
|
|
- }
|
|
|
|
- outputStream.write(bytesEnc, 0, index);
|
|
|
|
- }
|
|
|
|
- return outputStream;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|