|
@@ -37,7 +37,7 @@ import java.util.List;
|
|
|
* @author Cup
|
|
|
* @date 2022/4/15
|
|
|
*/
|
|
|
-@Component("CosTask")
|
|
|
+@Component("cosTask")
|
|
|
public class CosTask {
|
|
|
|
|
|
protected final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
|
|
@@ -70,7 +70,7 @@ public class CosTask {
|
|
|
// deliter表示分隔符, 设置为/表示列出当前目录下的object, 设置为空表示列出所有的object
|
|
|
listObjectsRequest.setDelimiter("/");
|
|
|
// 设置最大遍历出多少个对象, 一次listobject最大支持1000
|
|
|
- listObjectsRequest.setMaxKeys(500);
|
|
|
+ listObjectsRequest.setMaxKeys(10);
|
|
|
ObjectListing objectListing = null;
|
|
|
do {
|
|
|
try {
|
|
@@ -93,11 +93,11 @@ public class CosTask {
|
|
|
// 文件的路径key
|
|
|
String key = cosObjectSummary.getKey();
|
|
|
|
|
|
- if (key.length() < 6) {
|
|
|
+ if (key.length() < 2) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (".jpg_s".equals(key.substring(key.length() - 6))) {
|
|
|
+ if ("_s".equals(key.substring(key.length() - 2))) {
|
|
|
|
|
|
// 获取原图文件名
|
|
|
String picName = key.substring(0, key.length() - 2);
|
|
@@ -119,9 +119,9 @@ public class CosTask {
|
|
|
GetObjectRequest getObjectRequest = new GetObjectRequest(publicBucketName, key);
|
|
|
COSClient cosClient = QcloudFileUtils.getCosClient();
|
|
|
ObjectMetadata downObjectMeta = cosClient.getObject(getObjectRequest, downFile);
|
|
|
- FileInputStream fileInputStream = new FileInputStream(path);
|
|
|
+// FileInputStream fileInputStream = new FileInputStream(path);
|
|
|
String mimeType = "image/jpg";
|
|
|
- QcloudFileUtils.putStream(fileInputStream, key, publicBucketName, mimeType);
|
|
|
+// QcloudFileUtils.putStream(fileInputStream, key, publicBucketName, mimeType);
|
|
|
|
|
|
// 压缩图片
|
|
|
BufferedImage bufferedImage = ImageIO.read(downFile);
|
|
@@ -144,9 +144,9 @@ public class CosTask {
|
|
|
|
|
|
float scale = 500f / pWidth;
|
|
|
|
|
|
- Thumbnails.of(outFilePath).scale(scale).outputQuality(0.5f).toFile(outFilePath);
|
|
|
+ Thumbnails.of(outFilePath).scale(scale).outputQuality(0.8f).toFile(outFilePath);
|
|
|
}else {
|
|
|
- Thumbnails.of(outFilePath).scale(1f).outputQuality(0.5f).toFile(outFilePath);
|
|
|
+ Thumbnails.of(outFilePath).scale(1f).outputQuality(0.8f).toFile(outFilePath);
|
|
|
}
|
|
|
|
|
|
|