Search in sources :

Example 41 with CloudSDKException

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

the class AliyunObjectStorageServiceImpl method doDeleteObjects.

private void doDeleteObjects(String bucketName, Collection<String> objectNames) throws CloudSDKException {
    DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucketName);
    List<String> keyList = new ArrayList<>(objectNames);
    deleteObjectsRequest.setKeys(keyList);
    try {
        ossClient.deleteObjects(deleteObjectsRequest);
    // List<DeletedObject> deletedObjects = deleteResult.getDeletedObjects();
    } catch (OSSException e) {
        // List<DeleteError> deleteErrors = mde.getErrors();
        throw new CloudSDKException(e.getMessage(), e);
    } catch (ClientException e) {
        throw new CloudSDKException(e.getMessage(), e);
    } catch (Throwable e) {
        throw new CloudSDKException(e.getMessage(), e);
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) ArrayList(java.util.ArrayList) OSSException(com.aliyun.oss.OSSException) ClientException(com.aliyun.oss.ClientException) DeleteObjectsRequest(com.aliyun.oss.model.DeleteObjectsRequest)

Example 42 with CloudSDKException

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

the class AliyunObjectStorageServiceImpl method copyObject.

/**
 * {@inheritDoc}
 */
@Override
public void copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws CloudSDKException {
    try {
        CopyObjectRequest request = new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey);
        ossClient.copyObject(request);
    } catch (Throwable e) {
        throw new CloudSDKException(e.getMessage(), e);
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) CopyObjectRequest(com.aliyun.oss.model.CopyObjectRequest)

Example 43 with CloudSDKException

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

the class TestAliyunObjectStorageServiceImpl method testputObject.

@Test
public void testputObject() {
    String filePath = TestAliyunObjectStorageServiceImpl.class.getClassLoader().getResource("test.txt").getPath();
    File localFile = new File(filePath);
    try {
        objectStoreageService.putObject(BUCKETNAME, OBJECTNAME, localFile);
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) File(java.io.File) Test(org.junit.Test)

Example 44 with CloudSDKException

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

the class TestAliyunObjectStorageServiceImpl method testgenPresignedDownloadUrl.

@Test
public void testgenPresignedDownloadUrl() {
    try {
        long signExpired = 60 * 1000;
        URL url = objectStoreageService.genPresignedDownloadUrl(BUCKETNAME, OBJECTNAME, signExpired);
        System.out.println(url.toString());
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) URL(java.net.URL) Test(org.junit.Test)

Aggregations

CloudSDKException (com.mizhousoft.cloudsdk.CloudSDKException)44 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)14 Test (org.junit.Test)13 URL (java.net.URL)8 ObjectMetadata (com.mizhousoft.cloudsdk.oss.ObjectMetadata)6 File (java.io.File)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 RecognitionResult (com.mizhousoft.cloudsdk.nlp.RecognitionResult)3 Date (java.util.Date)3 GeneratePresignedUrlRequest (com.aliyun.oss.model.GeneratePresignedUrlRequest)2 TempCredential (com.mizhousoft.cloudsdk.TempCredential)2 OSSTempCredential (com.mizhousoft.cloudsdk.oss.OSSTempCredential)2 MediaMeta (com.mizhousoft.cloudsdk.vod.MediaMeta)2 CoverTypeEnum (com.mizhousoft.tencent.vod.constants.CoverTypeEnum)2 MediaTypeEnum (com.mizhousoft.tencent.vod.constants.MediaTypeEnum)2 GeneratePresignedUrlRequest (com.qcloud.cos.model.GeneratePresignedUrlRequest)2 VinOCRRequest (com.tencentcloudapi.ocr.v20181119.models.VinOCRRequest)2 VinOCRResponse (com.tencentcloudapi.ocr.v20181119.models.VinOCRResponse)2 CoverBySnapshotTaskInput (com.tencentcloudapi.vod.v20180717.models.CoverBySnapshotTaskInput)2