|  |  | @ -6,6 +6,7 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.codec.binary.Base64; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.io.IOUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.http.HttpEntity; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.http.HttpStatus; | 
			
		
	
	
		
			
				
					|  |  | @ -326,6 +327,23 @@ public class HttpClientManager { | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	public Result<byte[]> getMediaByteArray(String url, String json) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		try { | 
			
		
	
		
			
				
					|  |  |  | 			HttpPost httppost = new HttpPost(url); | 
			
		
	
		
			
				
					|  |  |  | 			httppost.setConfig(requestConfig); | 
			
		
	
		
			
				
					|  |  |  | 			httppost.addHeader("Content-Type", "application/json"); | 
			
		
	
		
			
				
					|  |  |  | 			if (StringUtils.isNotEmpty(json)) { | 
			
		
	
		
			
				
					|  |  |  | 				StringEntity se = new StringEntity(json, "utf-8"); | 
			
		
	
		
			
				
					|  |  |  | 				httppost.setEntity(se); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 			return executeToByte(httppost); | 
			
		
	
		
			
				
					|  |  |  | 		} catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  | 			log.error("sendGet exception", e); | 
			
		
	
		
			
				
					|  |  |  | 			return new Result<byte[]>().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	private Result<byte[]> executeToByte(HttpRequestBase httpMethod) { | 
			
		
	
		
			
				
					|  |  |  | 		CloseableHttpResponse response = null; | 
			
		
	
		
			
				
					|  |  |  | 		try { | 
			
		
	
	
		
			
				
					|  |  | @ -334,14 +352,16 @@ public class HttpClientManager { | 
			
		
	
		
			
				
					|  |  |  | 			if (response != null && response.getStatusLine() != null) { | 
			
		
	
		
			
				
					|  |  |  | 				if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { | 
			
		
	
		
			
				
					|  |  |  | 					InputStream in = response.getEntity().getContent(); | 
			
		
	
		
			
				
					|  |  |  | 					ByteArrayOutputStream output = new ByteArrayOutputStream(); | 
			
		
	
		
			
				
					|  |  |  | 					byte[] buffer = new byte[4096]; | 
			
		
	
		
			
				
					|  |  |  | 					int n = 0; | 
			
		
	
		
			
				
					|  |  |  | 					while (-1 != (n = in.read(buffer))) { | 
			
		
	
		
			
				
					|  |  |  | 						output.write(buffer, 0, n); | 
			
		
	
		
			
				
					|  |  |  | 					} | 
			
		
	
		
			
				
					|  |  |  | 					byte[] responseContent = IOUtils.toByteArray(in); | 
			
		
	
		
			
				
					|  |  |  | //					ByteArrayOutputStream output = new ByteArrayOutputStream();
 | 
			
		
	
		
			
				
					|  |  |  | //					byte[] buffer = new byte[4096];
 | 
			
		
	
		
			
				
					|  |  |  | //					int n = 0;
 | 
			
		
	
		
			
				
					|  |  |  | //					while (-1 != (n = in.read(buffer))) {
 | 
			
		
	
		
			
				
					|  |  |  | //						output.write(buffer, 0, n);
 | 
			
		
	
		
			
				
					|  |  |  | //					}
 | 
			
		
	
		
			
				
					|  |  |  | //					return new Result<byte[]>().ok(ArrayUtils.toObject(output.toByteArray()));
 | 
			
		
	
		
			
				
					|  |  |  | 					return new Result<byte[]>().ok(output.toByteArray()); | 
			
		
	
		
			
				
					|  |  |  | //					return new Result<byte[]>().ok(output.toByteArray());
 | 
			
		
	
		
			
				
					|  |  |  | 					return new Result<byte[]>().ok(responseContent); | 
			
		
	
		
			
				
					|  |  |  | 				} else { | 
			
		
	
		
			
				
					|  |  |  | 					log.warn("execute http method fail,httpStatus:{0}", response.getStatusLine().getStatusCode()); | 
			
		
	
		
			
				
					|  |  |  | 				} | 
			
		
	
	
		
			
				
					|  |  | 
 |