MongoDB::GridFS - A file storage utility
version 0.25
use MongoDB::GridFS; my $grid = $database->get_gridfs; my $fh = IO::File->new("myfile", "r"); $grid->insert($fh, {"filename" => "mydbfile"});
The number of bytes per chunk. Defaults to 1048576.
Collection in which file metadata is stored. Each document contains md5 and length fields, plus user-defined metadata (and an _id).
Actual content of the files stored. Each chunk contains up to 4Mb of data, as well as a number (its order within the file) and a files_id (the _id of the file in the files collection it belongs to).
my $file = $grid->find_one({"filename" => "foo.txt"});
Returns a matching MongoDB::GridFS::File or undef.
$grid->remove({"filename" => "foo.txt"});
Cleanly removes files from the database. If $just_one is given, only one file matching the criteria will be removed.
$just_one
my $id = $gridfs->insert($fh, {"content-type" => "text/html"});
Reads from a file handle into the database. Saves the file with the given metadata. The file handle must be readable.
@files = $grid->drop;
Removes all files' metadata and contents.
@files = $grid->all;
Returns a list of the files in the database.
Kristina Chodorow <kristina@mongodb.org>
To install MongoDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MongoDB
CPAN shell
perl -MCPAN -e shell install MongoDB
For more information on module installation, please visit the detailed CPAN module installation guide.