我无法从Amazon Cloudfront中托管的Java代码中读取图像
我们有运行在AmazonEC2中的图像处理服务器。我们有n个运行图像处理服务器的实例。它基本上从托管在amazon cdn中的源服务器读取图像 这里的问题是,图像是通过直接点击加载到浏览器中的,但在Java代码中,由于BuffereImage为null,我们得到了nullpointer异常。一段时间后,我们可以阅读图像,但需要几周的时间才能看到。这是一种罕见的情况,但却完全被卡住了。请对此提出建议 Via:1.1abc.cloudfront.net(cloudfront),1.0amazon-instnce-a.com:8080 (squid/2.6.STABLE21) 此处amazon-instnce-a.com:8080已终止,不再可用,但我们将请求路由到此的原因 用JAVA 6编写代码来检索图像的方法是什么?我们使用下面的代码片段来检索图像我无法从Amazon Cloudfront中托管的Java代码中读取图像,java,image,caching,amazon-ec2,amazon-cloudfront,Java,Image,Caching,Amazon Ec2,Amazon Cloudfront,我们有运行在AmazonEC2中的图像处理服务器。我们有n个运行图像处理服务器的实例。它基本上从托管在amazon cdn中的源服务器读取图像 这里的问题是,图像是通过直接点击加载到浏览器中的,但在Java代码中,由于BuffereImage为null,我们得到了nullpointer异常。一段时间后,我们可以阅读图像,但需要几周的时间才能看到。这是一种罕见的情况,但却完全被卡住了。请对此提出建议 Via:1.1abc.cloudfront.net(cloudfront),1.0amazon-
static HttpClient httpClient;
static void getImage(String uri){
HttpGet get = new HttpGet(uri);
try {
httpClient = HttpClientBuilder.create().build();
HttpResponse response = httpClient.execute(get);
HttpEntity entity = response.getEntity();
BufferedImage bufferedImage = null;
InputStream is = entity.getContent();
ImageIO.setUseCache(false);
bufferedImage = ImageIO.read(is);
if(bufferedImage == null){
System.out.println("null"); // we got null here
}
is.close();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
你点击的网址是什么?谢谢你的阅读。我们正在访问的亚马逊云交付网络URL。这是一个托管在Amazon CDN中的图像。