use of com.qcloud.cos.model.ObjectMetadata in project cos-java-sdk-v5 by tencentyun.
the class PutGetDelTest method testPutObjectWithChineseContentDisposition.
@Test
public void testPutObjectWithChineseContentDisposition() throws IOException {
ObjectMetadata originObjectMeta = new ObjectMetadata();
String disposition = "attachment;filename=\"" + UrlEncoderUtils.encode(new String("测试文件.txt".getBytes(), "UTF-8")) + ".jpg\"";
originObjectMeta.setContentDisposition(disposition);
testPutObjectByStreamDiffSize(0L, originObjectMeta);
}
use of com.qcloud.cos.model.ObjectMetadata in project cos-java-sdk-v5 by tencentyun.
the class PutObjectCopyTest method testCopySameRegion10MWithNewMetaData.
@Test
public void testCopySameRegion10MWithNewMetaData() throws IOException {
ObjectMetadata newObjectMetadata = new ObjectMetadata();
newObjectMetadata.setServerSideEncryption("AES256");
newObjectMetadata.setContentType("image/png");
newObjectMetadata.setCacheControl("no-cache");
testCopySameRegionDiffSize(10 * 1024 * 1024L, newObjectMetadata);
}
use of com.qcloud.cos.model.ObjectMetadata in project cos-java-sdk-v5 by tencentyun.
the class RestoreObjectTest method restoreObject.
@Test
public void restoreObject() {
InputStream input = new ByteArrayInputStream(new byte[10]);
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(10);
String key = "ut/aaa.txt";
PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, input, objectMetadata);
putObjectRequest.setStorageClass(StorageClass.Archive);
cosclient.putObject(putObjectRequest);
RestoreObjectRequest restoreObjectRequest = new RestoreObjectRequest(bucket, key, 1);
cosclient.restoreObject(restoreObjectRequest);
cosclient.deleteObject(bucket, key);
}
use of com.qcloud.cos.model.ObjectMetadata in project cos-java-sdk-v5 by tencentyun.
the class PutGetDelTest method testPutObjectWithGzipEncoding.
@Test
public void testPutObjectWithGzipEncoding() throws IOException {
ObjectMetadata originObjectMeta = new ObjectMetadata();
originObjectMeta.setContentEncoding("gzip");
testPutObjectByStreamDiffSize(1024 * 1024L, originObjectMeta);
}
use of com.qcloud.cos.model.ObjectMetadata in project cos-java-sdk-v5 by tencentyun.
the class CompleteMultipartUpload method call.
@Override
public UploadResult call() throws Exception {
CompleteMultipartUploadResult res;
try {
CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest(origReq.getBucketName(), origReq.getKey(), uploadId, collectPartETags()).withGeneralProgressListener(origReq.getGeneralProgressListener());
ObjectMetadata origMeta = origReq.getMetadata();
if (origMeta != null) {
ObjectMetadata objMeta = req.getObjectMetadata();
if (objMeta == null) {
objMeta = new ObjectMetadata();
}
objMeta.setUserMetadata(origMeta.getUserMetadata());
req.setObjectMetadata(objMeta);
}
if (origReq.getPicOperations() != null) {
req.setPicOperations(origReq.getPicOperations());
}
TransferManagerUtils.populateEndpointAddr(origReq, req);
res = cos.completeMultipartUpload(req);
} catch (Exception e) {
monitor.uploadFailed();
throw e;
}
UploadResult uploadResult = new UploadResult();
uploadResult.setBucketName(origReq.getBucketName());
uploadResult.setKey(origReq.getKey());
uploadResult.setETag(res.getETag());
uploadResult.setVersionId(res.getVersionId());
uploadResult.setRequestId(res.getRequestId());
uploadResult.setDateStr(res.getDateStr());
uploadResult.setCrc64Ecma(res.getCrc64Ecma());
uploadResult.setCiUploadResult(res.getCiUploadResult());
monitor.uploadComplete();
return uploadResult;
}
Aggregations