Search in sources :

Example 1 with ObjectMetadata

use of com.mizhousoft.cloudsdk.oss.ObjectMetadata in project cloud-sdk by mizhousoft.

the class COSObjectStorageServiceImpl method getObjectMetadata.

/**
 * {@inheritDoc}
 */
@Override
public ObjectMetadata getObjectMetadata(String bucketName, String objectName) throws CloudSDKException {
    try {
        ObjectMetadata objectMetadata = null;
        com.qcloud.cos.model.ObjectMetadata metadata = cosClient.getObjectMetadata(bucketName, objectName);
        if (null != metadata) {
            objectMetadata = new ObjectMetadata();
            objectMetadata.setContentLength(metadata.getContentLength());
            objectMetadata.setContentMD5(metadata.getContentMD5());
            objectMetadata.setContentType(metadata.getContentType());
            objectMetadata.setLastModified(metadata.getLastModified());
            objectMetadata.setObjectName(objectName);
            return objectMetadata;
        } else {
            throw new CloudSDKException("ObjectName not found.");
        }
    } catch (Throwable e) {
        throw new CloudSDKException(e.getMessage(), e);
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) ObjectMetadata(com.mizhousoft.cloudsdk.oss.ObjectMetadata)

Example 2 with ObjectMetadata

use of com.mizhousoft.cloudsdk.oss.ObjectMetadata in project cloud-sdk by mizhousoft.

the class AliyunObjectStorageServiceImpl method getObjectMetadata.

/**
 * {@inheritDoc}
 */
@Override
public ObjectMetadata getObjectMetadata(String bucketName, String objectName) throws CloudSDKException {
    try {
        ObjectMetadata objectMetadata = null;
        com.aliyun.oss.model.ObjectMetadata metadata = ossClient.getObjectMetadata(bucketName, objectName);
        if (null != metadata) {
            objectMetadata = new ObjectMetadata();
            objectMetadata.setContentLength(metadata.getContentLength());
            objectMetadata.setContentMD5(metadata.getContentMD5());
            objectMetadata.setContentType(metadata.getContentType());
            objectMetadata.setLastModified(metadata.getLastModified());
            objectMetadata.setObjectName(objectName);
            return objectMetadata;
        } else {
            throw new CloudSDKException("ObjectName not found.");
        }
    } catch (Throwable e) {
        throw new CloudSDKException(e.getMessage(), e);
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) ObjectMetadata(com.mizhousoft.cloudsdk.oss.ObjectMetadata)

Example 3 with ObjectMetadata

use of com.mizhousoft.cloudsdk.oss.ObjectMetadata in project cloud-sdk by mizhousoft.

the class TestAliyunObjectStorageServiceImpl method testgetObjectMetadata.

@Test
public void testgetObjectMetadata() {
    try {
        ObjectMetadata objectMetadata = objectStoreageService.getObjectMetadata(BUCKETNAME, OBJECTNAME);
        System.out.println(objectMetadata.toString());
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) ObjectMetadata(com.mizhousoft.cloudsdk.oss.ObjectMetadata) Test(org.junit.Test)

Example 4 with ObjectMetadata

use of com.mizhousoft.cloudsdk.oss.ObjectMetadata in project cloud-sdk by mizhousoft.

the class TestCOSObjectStorageServiceImpl method testgetObjectMetadata.

@Test
public void testgetObjectMetadata() {
    try {
        ObjectMetadata objectMetadata = objectStoreageService.getObjectMetadata(BUCKETNAME, OBJECTNAME);
        System.out.println(objectMetadata.getContentLength());
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) ObjectMetadata(com.mizhousoft.cloudsdk.oss.ObjectMetadata) Test(org.junit.Test)

Aggregations

CloudSDKException (com.mizhousoft.cloudsdk.CloudSDKException)4 ObjectMetadata (com.mizhousoft.cloudsdk.oss.ObjectMetadata)4 Test (org.junit.Test)2