Sorry I wasn't clear enough, let me give some additional info
I only need to store voicemail files in GridFS and associate them with external users (users that are not stored in mongodb). For this I use GridFS java API that allows me to do something like:
GridFSInputFile audioFile = vmFS.createFile(file);
audioFile.setFilename(file.getName());
audioFile.setMetaData(metadata);
audioFile.save();
where in metadata object I add additional info like user owner of vm, from where it was received, urgent flag or unheard flag, e.g.
BasicDBObject metadata = new BasicDBObject();
metadata.put(FROM, sender);
metadata.put(OWNER, userName);
metadata.put(NEW, newVm);
metadata.put(URGENT, urgent);
When I need to query for example new voicemails for a particular user I can do something like:
BasicDBObject query = new BasicDBObject();
query.put(OWNER, userName);
query.put(NEW, true);
vmFS.find(query);
Right now I am creating one files / chunks collections pair for each user e.g user george will have 2 collections - george.files and george.chunks and so on - by constructing GridFS object as '
GridFS vmFS = new GridFS(getVmdb(), username);
I could use the same approach but creating only the default collections fs.files and fs.chunks by creating GridFs object as
GridFS vmFS = new GridFS(getVmdb());
Hope this makes sense
Thanks!
George