use of com.qingstor.sdk.exception.QSException in project oss-spring-boot-starter by ArtIsLong.
the class QingYunOssClient method completeUpload.
@Override
public void completeUpload(UpLoadCheckPoint upLoadCheckPoint, List<UpLoadPartEntityTag> partEntityTags) {
try {
String uploadId = upLoadCheckPoint.getUploadId();
String key = upLoadCheckPoint.getKey();
Bucket.ListMultipartInput listMultipartInput = new Bucket.ListMultipartInput();
listMultipartInput.setUploadID(uploadId);
Bucket.ListMultipartOutput output = bucketClient.listMultipart(key, listMultipartInput);
List<Types.ObjectPartModel> objectParts = output.getObjectParts();
Bucket.CompleteMultipartUploadInput multipartUploadInput = new Bucket.CompleteMultipartUploadInput();
multipartUploadInput.setUploadID(uploadId);
multipartUploadInput.setObjectParts(objectParts);
bucketClient.completeMultipartUpload(key, multipartUploadInput);
FileUtil.del(upLoadCheckPoint.getCheckpointFile());
} catch (QSException e) {
throw new OssException(e);
}
}
use of com.qingstor.sdk.exception.QSException in project oss-spring-boot-starter by ArtIsLong.
the class QingYunOssClient method prepareUpload.
@Override
public void prepareUpload(UpLoadCheckPoint uploadCheckPoint, File upLoadFile, String targetName, String checkpointFile, SliceConfig slice) {
String bucket = getBucket();
String key = getKey(targetName, false);
uploadCheckPoint.setMagic(UpLoadCheckPoint.UPLOAD_MAGIC);
uploadCheckPoint.setUploadFile(upLoadFile.getPath());
uploadCheckPoint.setKey(key);
uploadCheckPoint.setBucket(bucket);
uploadCheckPoint.setCheckpointFile(checkpointFile);
uploadCheckPoint.setUploadFileStat(UpLoadFileStat.getFileStat(uploadCheckPoint.getUploadFile()));
long partSize = slice.getPartSize();
long fileLength = upLoadFile.length();
int parts = (int) (fileLength / partSize);
if (fileLength % partSize > 0) {
parts++;
}
uploadCheckPoint.setUploadParts(splitUploadFile(uploadCheckPoint.getUploadFileStat().getSize(), partSize));
uploadCheckPoint.setPartEntityTags(new ArrayList<>());
uploadCheckPoint.setOriginPartSize(parts);
try {
Bucket.InitiateMultipartUploadInput input = new Bucket.InitiateMultipartUploadInput();
Bucket.InitiateMultipartUploadOutput multipartUploadOutput = bucketClient.initiateMultipartUpload(key, input);
uploadCheckPoint.setUploadId(multipartUploadOutput.getUploadID());
} catch (QSException e) {
throw new OssException(e);
}
}
Aggregations