public void storeAttachment(AttachmentId attachmentId, InputStream data)
throws IOException {
GridFSInputFile file = getAttachmentGrid().createFile(data, attachmentId.serialise());
try {
file.save();
} catch (MongoException e) {
// Unfortunately, file.save() wraps any IOException thrown in a
// 'MongoException'. Since the interface explicitly throws IOExceptions,
// we unwrap any IOExceptions thrown.
Throwable innerException = e.getCause();