libmongo-client 0.1.4
Functions
Mongo GridFS Chunk API
Mongo GridFS API

This submodule provides chunk-based access to GridFS files. More...

Collaboration diagram for Mongo GridFS Chunk API:

Functions

mongo_sync_gridfs_chunked_file * mongo_sync_gridfs_chunked_find (mongo_sync_gridfs *gfs, const bson *query)
 Find a file on GridFS.
mongo_sync_gridfs_chunked_file * mongo_sync_gridfs_chunked_file_new_from_buffer (mongo_sync_gridfs *gfs, const bson *metadata, const guint8 *data, gint64 size)
 Upload a file to GridFS from a buffer.
void mongo_sync_gridfs_chunked_file_free (mongo_sync_gridfs_chunked_file *gfile)
 Free a GridFS chunked file object.
mongo_sync_cursor * mongo_sync_gridfs_chunked_file_cursor_new (mongo_sync_gridfs_chunked_file *gfile, gint start, gint num)
 Create a cursor for a GridFS chunked file.
guint8 * mongo_sync_gridfs_chunked_file_cursor_get_chunk (mongo_sync_cursor *cursor, gint32 *size)
 Get the data of a GridFS file chunk, via a cursor.

Detailed Description

This submodule provides chunk-based access to GridFS files.

Chunk-based access has the advantage of being reasonably lightweight and fast, and the disadvantage of making it harder to do arbitrary reads or multi-part writes.

It's best used when the whole file needs to be retrieved, or when uploading files that either fit in a buffer, or can be mmapped.


Function Documentation

guint8* mongo_sync_gridfs_chunked_file_cursor_get_chunk ( mongo_sync_cursor *  cursor,
gint32 *  size 
)

Get the data of a GridFS file chunk, via a cursor.

Once we have a cursor, it can be iterated over with mongo_sync_cursor_next(), and its data can be conveniently accessed with this function.

Parameters:
cursoris the cursor object to work with.
sizeis a pointer to a variable where the chunk's actual size can be stored.
Returns:
A pointer to newly allocated memory that holds the current chunk's data, or NULL on error. It is the responsibility of the caller to free this once it is no longer needed.

Definition at line 157 of file sync-gridfs-chunk.c.

Here is the call graph for this function:

mongo_sync_cursor* mongo_sync_gridfs_chunked_file_cursor_new ( mongo_sync_gridfs_chunked_file *  gfile,
gint  start,
gint  num 
)

Create a cursor for a GridFS chunked file.

The cursor can be used (via mongo_sync_gridfs_file_cursor_get_chunk()) to retrieve a GridFS file chunk by chunk.

Parameters:
gfileis the GridFS chunked file to work with.
startis the starting chunk.
numis the total number of chunks to make a cursor for.
Returns:
A newly allocated cursor object, or NULL on error. It is the responsibility of the caller to free the cursor once it is no longer needed.

Definition at line 125 of file sync-gridfs-chunk.c.

Here is the call graph for this function:

void mongo_sync_gridfs_chunked_file_free ( mongo_sync_gridfs_chunked_file *  gfile)

Free a GridFS chunked file object.

Parameters:
gfileis the file object to free.

Definition at line 28 of file sync-gridfs-chunk.c.

Here is the call graph for this function:

Here is the caller graph for this function:

mongo_sync_gridfs_chunked_file* mongo_sync_gridfs_chunked_file_new_from_buffer ( mongo_sync_gridfs *  gfs,
const bson *  metadata,
const guint8 *  data,
gint64  size 
)

Upload a file to GridFS from a buffer.

Create a new file on GridFS from a buffer, using custom meta-data.

Parameters:
gfsis the GridFS to create the file on.
metadatais the (optional) file metadata.
datais the data to store on GridFS.
sizeis the size of the data.
Returns:
A newly allocated file object, or NULL on error. It is the responsibility of the caller to free the returned object once it is no longer needed.
Note:
The metadata MUST NOT contain any of the required GridFS metadata fields (_id, length, chunkSize, uploadDate, md5), otherwise a conflict will occurr, against which the function does not guard by design.

Definition at line 196 of file sync-gridfs-chunk.c.

Here is the call graph for this function:

mongo_sync_gridfs_chunked_file* mongo_sync_gridfs_chunked_find ( mongo_sync_gridfs *  gfs,
const bson *  query 
)

Find a file on GridFS.

Finds a file on GridFS, based on a custom query.

Parameters:
gfsis the GridFS to find the file in.
queryis the custom query based on which the file shall be sought.
Returns:
A newly allocated chunked file object, or NULL on error. It is the responsibility of the caller to free the returned object once it is no longer needed.

Definition at line 42 of file sync-gridfs-chunk.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Enumerations Enumerator Defines