来自S3Object的BufferedImage

时间:2013-05-27 14:19:41

标签: java amazon-s3 inputstream javax.imageio

如何从S3Object获取BufferedImage?我猜想我会想念ImageIO读卡器吗?!这是我试过的。它抛出NullPointerException:

S3Object o = s3Client.getObject("testbucket", "test.jpeg");
logger.debug(o.getObjectMetadata().getContentLength()); // 25890
logger.debug(o.getObjectMetadata().getContentType()); // image/jpeg

ImageInputStream iin = ImageIO.createImageInputStream(o.getObjectContent());
BufferedImage img = ImageIO.read(iin);  

logger.debug(img.getHeight()); // NullPointerException

感谢您的帮助!

0 个答案:

没有答案