I am uploading images using servlet. To perform resize operations i am converting InputStream to BufferedImage. Now i want to save it in mongoDB. Since, i am new to mongoDB as far as i know, GridFS takes InputStream.
So, is there any way to convert BufferedImage to InputStream?
You need to save the BufferedImage to a ByteArrayOutputStream
using the ImageIO
class, then create a ByteArrayInputStream
from toByteArray()
.