Search in sources :

Example 1 with Bucket

use of com.qingstor.sdk.service.Bucket in project oss-spring-boot-starter by ArtIsLong.

the class QingYunOssClient method move.

@Override
public void move(String sourceName, String targetName, Boolean isOverride) {
    String bucket = getBucket();
    String newSourceName = getKey(sourceName, false);
    String newTargetName = getKey(targetName, false);
    if (isOverride || !isExist(targetName)) {
        try {
            Bucket.PutObjectInput input = new Bucket.PutObjectInput();
            input.setXQSMoveSource(StrUtil.SLASH + bucket + StrUtil.SLASH + newSourceName);
            bucketClient.putObject(newTargetName, input);
        } catch (Exception e) {
            throw new OssException(e);
        }
    }
}
Also used : Bucket(com.qingstor.sdk.service.Bucket) OssException(io.github.artislong.exception.OssException) QSException(com.qingstor.sdk.exception.QSException) OssException(io.github.artislong.exception.OssException)

Example 2 with Bucket

use of com.qingstor.sdk.service.Bucket in project oss-spring-boot-starter by ArtIsLong.

the class QingYunOssConfiguration method qingYunOssClient.

public StandardOssClient qingYunOssClient(QingYunOssConfig qingYunOssConfig) {
    QingStor qingStor = qingStor(qingYunOssConfig);
    Bucket bucket = qingStor.getBucket(qingYunOssConfig.getBucketName(), qingYunOssConfig.getZone());
    return new QingYunOssClient(qingStor, bucket, qingYunOssConfig);
}
Also used : QingStor(com.qingstor.sdk.service.QingStor) Bucket(com.qingstor.sdk.service.Bucket)

Example 3 with Bucket

use of com.qingstor.sdk.service.Bucket in project oss-spring-boot-starter by ArtIsLong.

the class QingYunOssClient method copy.

@Override
public void copy(String sourceName, String targetName, Boolean isOverride) {
    String bucket = getBucket();
    String newSourceName = getKey(sourceName, false);
    String newTargetName = getKey(targetName, false);
    if (isOverride || !isExist(targetName)) {
        try {
            Bucket.PutObjectInput input = new Bucket.PutObjectInput();
            input.setXQSCopySource(StrUtil.SLASH + bucket + StrUtil.SLASH + newSourceName);
            bucketClient.putObject(newTargetName, input);
        } catch (Exception e) {
            throw new OssException(e);
        }
    }
}
Also used : Bucket(com.qingstor.sdk.service.Bucket) OssException(io.github.artislong.exception.OssException) QSException(com.qingstor.sdk.exception.QSException) OssException(io.github.artislong.exception.OssException)

Example 4 with Bucket

use of com.qingstor.sdk.service.Bucket 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

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