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.
More...
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
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.
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.
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.
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.
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.
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.
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.
Close and free a GridFS object.
- Parameters:
-
gfs | is the GridFS object to free up. |
disconnect | signals whether to free the underlying connection aswell. |
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.
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.
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.
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.
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.