Search in sources :

Example 26 with CloudSDKException

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

the class TestSensitiveWordsRecognitionServiceImpl method testRecognize.

@Test
public void testRecognize() {
    String text = "我的敏感词包二奶仓井空";
    try {
        RecognitionResult result = this.sensitiveWordsRecognitionService.recognize(text);
        Assert.assertTrue(result.isContainSensitiveWord());
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) RecognitionResult(com.mizhousoft.cloudsdk.nlp.RecognitionResult) Test(org.junit.Test)

Example 27 with CloudSDKException

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

the class TestTencentOCRServiceImpl method getTempCredential.

@Test
public void getTempCredential() {
    try {
        TempCredential tempCredential = ocrService.getTempCredential(30);
        Assert.assertNotNull(tempCredential);
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TempCredential(com.mizhousoft.cloudsdk.TempCredential) Test(org.junit.Test)

Example 28 with CloudSDKException

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

the class TestCOSObjectStorageServiceImpl method testgenPresignedUploadUrl.

@Test
public void testgenPresignedUploadUrl() {
    String objectName = "/pre/testd/test.txt";
    URL url = null;
    try {
        String filePath = TestCOSObjectStorageServiceImpl.class.getClassLoader().getResource("test.txt").getPath();
        File localFile = new File(filePath);
        String contentMd5 = FileDigestUtils.md5AsBase64(localFile);
        long signExpired = 60 * 1000;
        url = objectStoreageService.genPresignedUploadUrl(BUCKETNAME, objectName, signExpired, contentMd5);
        System.out.println(url.toString());
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("PUT");
        connection.setRequestProperty("content-md5", contentMd5);
        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
        FileInputStream fStream = new FileInputStream(localFile);
        int bufferSize = 1024;
        byte[] buffer = new byte[bufferSize];
        int length = -1;
        while ((length = fStream.read(buffer)) != -1) {
            out.write(buffer, 0, length);
        }
        fStream.close();
        out.close();
        int responseCode = connection.getResponseCode();
        System.out.println("Service returned response code " + responseCode);
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    } catch (ProtocolException e) {
        Assert.fail(e.getMessage());
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) ProtocolException(java.net.ProtocolException) HttpURLConnection(java.net.HttpURLConnection) DataOutputStream(java.io.DataOutputStream) IOException(java.io.IOException) File(java.io.File) URL(java.net.URL) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 29 with CloudSDKException

use of com.mizhousoft.cloudsdk.CloudSDKException 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)

Example 30 with CloudSDKException

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

the class TestQCloudVODServiceImpl method getVideoMeta.

@Test
public void getVideoMeta() {
    try {
        MediaMeta mediaMeta = vodService.getVideoMeta("5285890786997530566");
        Assert.assertNotNull(mediaMeta);
    } catch (CloudSDKException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) MediaMeta(com.mizhousoft.cloudsdk.vod.MediaMeta) 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