Loading...
Searching...
No Matches
Mongo GridFS API
Mongo Sync API
Collaboration diagram for Mongo GridFS API:

## Topics

| Mongo GridFS Chunk API
| This submodule provides chunk-based access to GridFS files.
| Mongo GridFS Streaming API
| Ths submodule provides stream-based access to GridFS files.

## Functions

mongo_sync_gridfs * | mongo_sync_gridfs_new (mongo_sync_connection *conn, const gchar *ns_prefix)
| Create a new GridFS object.
void | mongo_sync_gridfs_free (mongo_sync_gridfs *gfs, gboolean disconnect)
| Close and free a GridFS object.
gint32 | mongo_sync_gridfs_get_chunk_size (mongo_sync_gridfs *gfs)
| Get the default chunk size of a GridFS object.
gboolean | mongo_sync_gridfs_set_chunk_size (mongo_sync_gridfs *gfs, gint32 chunk_size)
| Set the default chunk size of a GridFS object.
mongo_sync_cursor * | mongo_sync_gridfs_list (mongo_sync_gridfs *gfs, const bson *query)
| List GridFS files matching a query.
gboolean | mongo_sync_gridfs_remove (mongo_sync_gridfs *gfs, const bson *query)
| Delete files matching a query from GridFS.
const guint8 * | mongo_sync_gridfs_file_get_id (gpointer gfile)
| Get the file ID of a GridFS file.
gint64 | mongo_sync_gridfs_file_get_length (gpointer gfile)
| Get the length of a GridFS file.
gint32 | mongo_sync_gridfs_file_get_chunk_size (gpointer gfile)
| Get the chunk size of a GridFS file.
const gchar * | mongo_sync_gridfs_file_get_md5 (gpointer gfile)
| Get the MD5 digest of a GridFS file.
gint64 | mongo_sync_gridfs_file_get_date (gpointer gfile)
| Get the upload date of a GridFS file.
const bson * | mongo_sync_gridfs_file_get_metadata (gpointer gfile)
| Get the full metadata of a GridFS file.
gint64 | mongo_sync_gridfs_file_get_chunks (gpointer gfile)
| Get the number of chunks in a GridFS file.

## Detailed Description

The GridFS API - and related modules, like Mongo GridFS Chunk API and Mongo GridFS Streaming API - provide a conveneint way to work with GridFS, and files stored on it.

This module implements the GridFS support functions, which allow one to connect to or create new GridFS instances, list or remove files, or retrieve metadata about files opened by one of the sub-modules.

## Function Documentation

## mongo_sync_gridfs_file_get_chunk_size()

gint32 mongo_sync_gridfs_file_get_chunk_size | ( | gpointer | gfile | ) |

Get the chunk size of a GridFS file.

Parameters

  gfile | is the GridFS file to work with.

Returns
  The maximum size of the chunks of the file, or -1 on error.

## mongo_sync_gridfs_file_get_chunks()

gint64 mongo_sync_gridfs_file_get_chunks | ( | gpointer | gfile | ) |

Get the number of chunks in a GridFS file.

Parameters

  gfile | is the GridFS file to work with.

Returns
  The number of chunks in the GridFS file, or -1 on error.

## mongo_sync_gridfs_file_get_date()

gint64 mongo_sync_gridfs_file_get_date | ( | gpointer | gfile | ) |

Get the upload date of a GridFS file.

Parameters

  gfile | is the GridFS file to work with.

Returns
  The upload date of the file, or -1 on error.

## mongo_sync_gridfs_file_get_id()

const guint8 * mongo_sync_gridfs_file_get_id | ( | gpointer | gfile | ) |

Get the file ID of a GridFS file.

Parameters

  gfile | is the GridFS file to work with.

Returns
  The ObjectID of the file, or NULL on error. The returned pointer points to an internal area, and should not be modified or freed, and is only valid as long as the file object is valid.

## mongo_sync_gridfs_file_get_length()

gint64 mongo_sync_gridfs_file_get_length | ( | gpointer | gfile | ) |

Get the length of a GridFS file.

Parameters

  gfile | is the GridFS file to work with.

Returns
  The length of the file, or -1 on error.

## mongo_sync_gridfs_file_get_md5()

const gchar * mongo_sync_gridfs_file_get_md5 | ( | gpointer | gfile | ) |

Get the MD5 digest of a GridFS file.

Parameters

  gfile | is the GridFS file to work with.

Returns
  The MD5 digest of the file, or NULL on error. The returned pointer points to an internal area, and should not be modified or freed, and is only valid as long as the file object is valid.

## mongo_sync_gridfs_file_get_metadata()

const bson * mongo_sync_gridfs_file_get_metadata | ( | gpointer | gfile | ) |

Get the full metadata of a GridFS file.

Parameters

  gfile | is the GridFS file to work with.

Returns
  A BSON object containing the full metadata, or NULL on error. The returned pointer points to an internal area, and should not be modified or freed, and is only valid as long as the file object is valid.

## mongo_sync_gridfs_free()

void mongo_sync_gridfs_free | ( | mongo_sync_gridfs * | gfs,
|  | gboolean | disconnect )

Close and free a GridFS object.

Parameters

  gfs | is the GridFS object to free up.
  disconnect | signals whether to free the underlying connection aswell.

## mongo_sync_gridfs_get_chunk_size()

gint32 mongo_sync_gridfs_get_chunk_size | ( | mongo_sync_gridfs * | gfs | ) |

Get the default chunk size of a GridFS object.

Parameters

  gfs | is the GridFS object to get the default chunk size of.

Returns
  The chunk size in bytes, or -1 on error.

## mongo_sync_gridfs_list()

mongo_sync_cursor * mongo_sync_gridfs_list | ( | mongo_sync_gridfs * | gfs,
|  | const bson * | query )

List GridFS files matching a query.

Finds all files on a GridFS, based on a custom query.

Parameters

  gfs | is the GridFS to list files from.
  query | is the custom query based on which files shall be sought. Passing a NULL query will find all files, without restriction.

Returns
  A newly allocated cursor object, or NULL on error. It is the responsibility of the caller to free the returned cursor once it is no longer needed.

## mongo_sync_gridfs_new()

mongo_sync_gridfs * mongo_sync_gridfs_new | ( | mongo_sync_connection * | conn,
|  | const gchar * | ns_prefix )

Create a new GridFS object.

Parameters

  conn | is the MongoDB connection to base the filesystem object on.
  ns_prefix | is the prefix the GridFS collections should be under.

Returns
  A newly allocated GridFS object, or NULL on error.

## mongo_sync_gridfs_remove()

gboolean mongo_sync_gridfs_remove | ( | mongo_sync_gridfs * | gfs,
|  | const bson * | query )

Delete files matching a query from GridFS.

Finds all files on a GridFS, based on a custom query, and removes them.

Parameters

  gfs | is the GridFS to delete files from.
  query | is the custom query based on which files shall be sought. Passing a NULL query will find all files, without restriction.

Returns
  TRUE if all files were deleted successfully, FALSE otherwise.

## mongo_sync_gridfs_set_chunk_size()

gboolean mongo_sync_gridfs_set_chunk_size | ( | mongo_sync_gridfs * | gfs,
|  | gint32 | chunk_size )

Set the default chunk size of a GridFS object.

Parameters

  gfs | is the GridFS object to set the default chunk size of.
  chunk_size | is the desired default chunk size.

Returns
  TRUE on success, FALSE otherwise.