Search in sources :

Example 1 with AppendObjectResult

use of com.qcloud.cos.model.AppendObjectResult in project cos-java-sdk-v5 by tencentyun.

the class AbstractCOSClientTest method testAppendGetDelObjectDiffSize.

protected void testAppendGetDelObjectDiffSize(long size, boolean isStream) throws IOException {
    String key = "ut/" + size;
    long nextAppendPosition = 0;
    for (int i = 0; i < 3; i++) {
        File localFile = buildTestFile(size);
        AppendObjectRequest appendObjectRequest = null;
        if (!isStream) {
            appendObjectRequest = new AppendObjectRequest(bucket, key, localFile);
        } else {
            ObjectMetadata objectMetadata = new ObjectMetadata();
            objectMetadata.setContentLength(size);
            appendObjectRequest = new AppendObjectRequest(bucket, key, new FileInputStream(localFile), objectMetadata);
        }
        appendObjectRequest.setPosition(nextAppendPosition);
        AppendObjectResult appendObjectResult = cosclient.appendObject(appendObjectRequest);
        nextAppendPosition = appendObjectResult.getNextAppendPosition();
        localFile.delete();
    }
    ObjectMetadata objectMetadata = cosclient.getObjectMetadata(bucket, key);
    assertEquals(objectMetadata.getContentLength(), size * 3);
    cosclient.deleteObject(bucket, key);
}
Also used : AppendObjectRequest(com.qcloud.cos.model.AppendObjectRequest) File(java.io.File) ObjectMetadata(com.qcloud.cos.model.ObjectMetadata) FileInputStream(java.io.FileInputStream) AppendObjectResult(com.qcloud.cos.model.AppendObjectResult)

Aggregations

AppendObjectRequest (com.qcloud.cos.model.AppendObjectRequest)1 AppendObjectResult (com.qcloud.cos.model.AppendObjectResult)1 ObjectMetadata (com.qcloud.cos.model.ObjectMetadata)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1