Save and Stream video files without GridFS (with node.js and mongoose)

1,226 views
Skip to first unread message

msdark

unread,
Jul 25, 2011, 4:24:48 PM7/25/11
to mongodb-user
(sorry for my english)
Hi.
I read some about storing binary files (like videos) into MongoDB.
It's possible to use GridFS or no..
Mongodb database support files up to 16MB .. my videos are between
600kb and 2 mB so i think in not to use GridFS .. instead of that use
the same database with a embedded document to store my videos.


I have this Schema:

Document1 {
nombre:
notification: [Notifications]
}

Notifications{
nombre:
video:
}

It's possible to store the binary data (video) into the Notifications
Document and then use some query to retrieve and show into a webpage.

I use node.js and mogoose.

Any idea, guideline or comment?

Any help would be very appreciate.

Thanks in advance

Scott Hernandez

unread,
Jul 25, 2011, 9:13:33 PM7/25/11
to mongod...@googlegroups.com
Yes, you can do this but each document has a limited size (4/16MB
depending on the server version).

If you use gridfs you can store larger files.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

msdark

unread,
Jul 26, 2011, 3:21:34 PM7/26/11
to mongodb-user
So.. my version of mongodb support files up to 16MB so i can save
video/images files..

But how??

Do i need to read the file, save into Buffer and then save into BD??
fs.readFile('file.mp4',function(err,data){
Document.findById(id,function(err,doc)){
embed = new Embedd({binary_data:data});
doc.embed.push(embed);
doc.save();
});
});

(is this snippet correct??)

or i need to implement other method?...

I try to use GridFS but i can't access to native objects (GridFSStore
and DB) from mongoose, so my solution must be insert into a document.

Thanks in advance

Richard Kreuter

unread,
Aug 11, 2011, 2:44:11 PM8/11/11
to mongodb-user
If nobody on this list can help you with the mongoose API (I'm sorry
to say I can't), perhaps you could ask the mongoose developers?

http://mongoosejs.com/

Regards,
Richard
Reply all
Reply to author
Forward
0 new messages