}\r
\r
private void readImageLength() throws ClientProtocolException, IOException, HttpException{\r
- long length = UriUtils.getResourceLength(imageUri, null);\r
- setLength(length);\r
+ try {\r
+ long length = UriUtils.getResourceLength(imageUri, null);\r
+ setLength(length);\r
+ } catch (HttpException e) {\r
+ if (e.getMessage().equals("Could not retrieve Content-Length")){\r
+ InputStream inputStream = UriUtils.getInputStream(imageUri);\r
+ int n = 0;\r
+ while(inputStream.read() != -1){\r
+ n++;\r
+ }\r
+ inputStream.close();\r
+ logger.info("Content-Length not available in http header. Image size computed via input stream size: " + imageUri);\r
+ setLength(n);\r
+ }else{\r
+ throw e;\r
+ }\r
+ }\r
}\r
\r
/**\r
if(imageInfo != null){
imageFile.setHeight(imageInfo.getHeight());
imageFile.setWidth(imageInfo.getWidth());
-// imageFile.setSize((int)imageInfo.getLength());
+ if(imageInfo.getLength() != 0){
+ imageFile.setSize((int)imageInfo.getLength());
+ }
}
return imageFile;