Search in sources :

Example 1 with RestoreObjectRequest

use of com.qcloud.cos.model.RestoreObjectRequest 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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RestoreObjectRequest(com.qcloud.cos.model.RestoreObjectRequest) ObjectMetadata(com.qcloud.cos.model.ObjectMetadata) PutObjectRequest(com.qcloud.cos.model.PutObjectRequest) Test(org.junit.Test)

Aggregations

ObjectMetadata (com.qcloud.cos.model.ObjectMetadata)1 PutObjectRequest (com.qcloud.cos.model.PutObjectRequest)1 RestoreObjectRequest (com.qcloud.cos.model.RestoreObjectRequest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1