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);
}
}
}
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);
}
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);
}
}
}
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);
}
}
Aggregations