NAME
MongoDB::GridFS - A file storage utility
VERSION
version 0.24
SYNOPSIS
use MongoDB::GridFS;
my $grid = $database->get_gridfs;
my $fh = IO::File->new("myfile", "r");
$grid->insert($fh, {"filename" => "mydbfile"});
ATTRIBUTES
chunk_size
The number of bytes per chunk. Defaults to 1048576.
files
Collection in which file metadata is stored. Each document contains md5 and length fields, plus user-defined metadata (and an _id).
chunks
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).
METHODS
find_one ($criteria, $fields)
my $file = $grid->find_one({"filename" => "foo.txt"});
Returns a matching MongoDB::GridFS::File or undef.
remove ($criteria, $just_one)
$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.
insert ($fh, $metadata)
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.
drop
@files = $grid->drop;
Removes all files' metadata and contents.
all
@files = $grid->all;
Returns a list of the files in the database.
AUTHOR
Kristina Chodorow <kristina@mongodb.org>