Skip to content

Commit

Permalink
Merge pull request #173 from jamebal/develop
Browse files Browse the repository at this point in the history
fix: 修复minio上传文件超过5G会丢失文件的问题
  • Loading branch information
jamebal authored Nov 26, 2024
2 parents ec7a6f4 + 54fc1b6 commit 6ec925e
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/main/java/com/jmal/clouddisk/oss/minio/MinIOService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import java.nio.file.Path;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledThreadPoolExecutor;
Expand Down Expand Up @@ -366,14 +363,36 @@ public CopyOnWriteArrayList<Integer> getListParts(String objectName, String uplo
private List<Part> getPartsList(String objectName, String uploadId) {
List<Part> listParts = new ArrayList<>();
try {
ListPartsResponse partResult = this.minIoClient.listMultipart(bucketName, null, objectName, 1000, 0, uploadId);
return partResult.result().partList();
int maxParts = 1000;
int partNumberMarker = 0;
boolean isTruncated;

do {
ListPartsResponse partResult = this.minIoClient.listMultipart(bucketName, null, objectName, maxParts, partNumberMarker, uploadId);
List<Part> currentParts = partResult.result().partList();

if (currentParts.isEmpty()) {
return Collections.emptyList();
}

listParts.addAll(currentParts);
isTruncated = partResult.result().isTruncated();

if (isTruncated) {
partNumberMarker = currentParts.get(currentParts.size() - 1).partNumber();
}
} while (isTruncated);

} catch (Exception e) {
log.error(e.getMessage(), e);
log.error("Error listing parts for object: {}, uploadId: {}. Exception: {}", objectName, uploadId, e.getMessage(), e);
return Collections.emptyList();
}
return listParts;
}




private void getMultipartUploads() {
}

Expand Down

0 comments on commit 6ec925e

Please sign in to comment.