|
@@ -21,6 +21,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.exception.ExamCloudRuntimeException;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.helpers.JsonHttpResponseHolder;
|
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
@@ -185,10 +186,22 @@ public class FaceppClient {
|
|
|
String imageBase64 = null;
|
|
|
try {
|
|
|
response = httpclient.execute(get);
|
|
|
+
|
|
|
+ if (HttpStatus.SC_OK != response.getStatusLine().getStatusCode()) {
|
|
|
+ throw new StatusException("601", "fail to download file. url=" + backupImageUrl);
|
|
|
+ }
|
|
|
+
|
|
|
byte[] byteArray = EntityUtils.toByteArray(response.getEntity());
|
|
|
+ if (100 > byteArray.length) {
|
|
|
+ throw new StatusException("602", "invalid image size. url=" + backupImageUrl);
|
|
|
+ }
|
|
|
+
|
|
|
imageBase64 = Base64.encodeBase64String(byteArray);
|
|
|
+
|
|
|
+ } catch (StatusException e) {
|
|
|
+ throw e;
|
|
|
} catch (Exception e) {
|
|
|
- throw new ExamCloudRuntimeException(e);
|
|
|
+ throw new StatusException("603", "fail to download file. url=" + backupImageUrl, e);
|
|
|
} finally {
|
|
|
IOUtils.closeQuietly(response);
|
|
|
}
|