Search in sources :

Example 1 with QSException

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);
    }
}
Also used : QSException(com.qingstor.sdk.exception.QSException) Bucket(com.qingstor.sdk.service.Bucket) OssException(io.github.artislong.exception.OssException)

Example 2 with QSException

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);
    }
}
Also used : QSException(com.qingstor.sdk.exception.QSException) Bucket(com.qingstor.sdk.service.Bucket) DownloadCheckPoint(io.github.artislong.model.download.DownloadCheckPoint) OssException(io.github.artislong.exception.OssException)

Aggregations

QSException (com.qingstor.sdk.exception.QSException)2 Bucket (com.qingstor.sdk.service.Bucket)2 OssException (io.github.artislong.exception.OssException)2 DownloadCheckPoint (io.github.artislong.model.download.DownloadCheckPoint)1