Creating a MongoDb OutputStream

100 views
Skip to first unread message

sim...@googlemail.com

unread,
Sep 21, 2010, 5:07:30 AM9/21/10
to mongodb-user
Hi,

I'm very new to mongoDb, we would like to store files using the Java
drivers in mongoDb to help manage files rather than using the file
system.


Currently we have a process which Encrypts files using Bouncycastle
and then storing the files on the file system.

We would like to get away from the file system and store the encrypted
files in mongoDb but having a few issues with heap space errors with
large files.

Is there any way of writing the Bouncycastle OutputStream directly
into mongoDb using GridFs?

For testing we currently get the OutputStream from BC then convert it
to an InputStream then use GridFs.createFile(InputStream is) to store
the file.

Is there any easier way of doing this process?

Regards,
Matt

Alvin Richards

unread,
Sep 21, 2010, 7:37:39 AM9/21/10
to mongodb-user
When you create a new file object in GridFS, one constructor accepts
an InputStream

http://api.mongodb.org/java/current/com/mongodb/gridfs/GridFS.html#createFile(java.io.InputStream)

I don't know the details about bouncycastle, but this would look like
the way to go.

-Alvin

On Sep 21, 5:07 am, "sims...@googlemail.com" <sims...@googlemail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages