use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TestQCloudVODServiceImpl method uploadVideo.
@Test
public void uploadVideo() {
String filePath = TestQCloudVODServiceImpl.class.getClassLoader().getResource("test.mp4").getPath();
File mediaFile = new File(filePath);
filePath = TestQCloudVODServiceImpl.class.getClassLoader().getResource("test-p.jpg").getPath();
File coverFile = new File(filePath);
try {
vodService.uploadVideo(mediaFile, coverFile);
} catch (CloudSDKException e) {
Assert.fail(e.getMessage());
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TencentOCRServiceImpl method imageUrlOCR.
/**
* {@inheritDoc}
*/
@Override
public String imageUrlOCR(String imageUrl) throws CloudSDKException {
VinOCRRequest req = new VinOCRRequest();
req.setImageUrl(imageUrl);
try {
VinOCRResponse resp = ocrClient.VinOCR(req);
return resp.getVin();
} catch (TencentCloudSDKException e) {
throw new CloudSDKException(e.getMessage(), e);
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TencentOCRServiceImpl method imageBase64OCR.
/**
* {@inheritDoc}
*/
@Override
public String imageBase64OCR(String imageBase64) throws CloudSDKException {
VinOCRRequest req = new VinOCRRequest();
req.setImageBase64(imageBase64);
try {
VinOCRResponse resp = ocrClient.VinOCR(req);
return resp.getVin();
} catch (TencentCloudSDKException e) {
throw new CloudSDKException(e.getMessage(), e);
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TencentOCRServiceImpl method getTempCredential.
/**
* {@inheritDoc}
*/
@Override
public TempCredential getTempCredential(long durationSecond) throws CloudSDKException {
GetFederationTokenRequest request = new GetFederationTokenRequest();
request.setName("ocr");
request.setDurationSeconds(durationSecond);
request.setPolicy("{\"version\": \"2.0\", \"statement\": [{\"action\": [\"ocr:*\"], \"resource\": \"*\", \"effect\": \"allow\"}]}");
try {
GetFederationTokenResponse response = cosClient.GetFederationToken(request);
Credentials credential = response.getCredentials();
TempCredential tempCredential = new TempCredential();
tempCredential.setSecretId(credential.getTmpSecretId());
tempCredential.setSecretKey(credential.getTmpSecretKey());
tempCredential.setToken(credential.getToken());
tempCredential.setExpiredTime(response.getExpiredTime());
return tempCredential;
} catch (TencentCloudSDKException e) {
throw new CloudSDKException(e.getMessage(), e);
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class COSObjectStorageServiceImpl method putObject.
/**
* {@inheritDoc}
*/
@Override
public void putObject(String bucketName, String objectName, InputStream input, long contentLength, String contentType) throws CloudSDKException {
try {
com.qcloud.cos.model.ObjectMetadata metadata = new com.qcloud.cos.model.ObjectMetadata();
metadata.setContentLength(contentLength);
metadata.setContentType(contentType);
cosClient.putObject(bucketName, objectName, input, metadata);
} catch (Throwable e) {
throw new CloudSDKException(e.getMessage(), e);
} finally {
try {
input.close();
} catch (Throwable e) {
LOG.error("Close file input stream failed.", e);
}
}
}
Aggregations