Platforms to show: All Mac Windows Linux Cross-Platform

Back to MongoGridFSFileMBS class.

MongoGridFSFileMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The private constructor.

MongoGridFSFileMBS.NewStream as MongoStreamMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
create a new Stream to read from and write to a GridFS file.
Example
Var GridFS As MongoGridFSMBS = Client.GridFS("test", "fs")

// now find the file and read it
Var file As MongoGridFSFileMBS = GridFS.FindOneByFileName( "test.txt")

// open a stream
Var stream As MongoStreamMBS = file.NewStream

// write new content
Var bytes As Integer = stream.Write("Just a test! more bytes")
MessageBox "bytes written: "+bytes.ToString

// this will do file.save internally
stream.Close

GridFS files are created with CreateFile() or CreateFileFromStream().

This function does not transfer ownership of file. Therefore, file must remain valid for the lifetime of this stream.

Note, the returned stream uses the “socketTimeoutMS” and “connectTimeoutMS” values from the MongoDB URI.

Some examples using this method:

MongoGridFSFileMBS.Read(ByteCount as Integer, MinBytes as Integer = -1) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads given number of bytes as String.

MinBytes: The minimum number of bytes that must be read or an error will be synthesized.

This function performs a scattered read from file, potentially blocking to read from the MongoDB server.

MongoGridFSFileMBS.ReadAll as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads all data into a string.

This function performs a scattered read from file, potentially blocking to read from the MongoDB server.

MongoGridFSFileMBS.ReadAllMemory as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads all data into Memoryblock.

This function performs a scattered read from file, potentially blocking to read from the MongoDB server.

MongoGridFSFileMBS.ReadMemory(ByteCount as Integer, MinBytes as Integer = -1) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads given number of bytes as MemoryBlock.

MinBytes: The minimum number of bytes that must be read or an error will be synthesized.

This function performs a scattered read from file, potentially blocking to read from the MongoDB server.

MongoGridFSFileMBS.Remove

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Removes file and its data chunks from the MongoDB server.

MongoGridFSFileMBS.Save

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Saves modifications to file to the MongoDB server.

Modifying GridFS files is NOT thread-safe. Only one thread or process can access a GridFS file while it is being modified.

MongoGridFSFileMBS.Seek(delta as Int64, whence as Integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Adjust the file position pointer in the given file by delta, starting from the position whence.

The whence argument is interpreted as in fseek:

SeekSetSet the position relative to the start of the file.
SeekCurrentMove delta relative to the current file position.
SeekEndMove delta relative to the end of the file.

On success, the file’s underlying position pointer is set appropriately. On failure, the file position is NOT changed and an exception is raised.

MongoGridFSFileMBS.Write(Data as MemoryBlock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Performs a gathered write to the underlying gridfs file.

Modifying GridFS files is NOT thread-safe. Only one thread or process can access a GridFS file while it is being modified.

Returns the number of bytes written.

See also:

MongoGridFSFileMBS.Write(Data as String) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MongoDB MBS MongoDB Plugin 25.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Performs a gathered write to the underlying gridfs file.

Modifying GridFS files is NOT thread-safe. Only one thread or process can access a GridFS file while it is being modified.

Returns the number of bytes written.

See also:

The items on this page are in the following plugins: MBS MongoDB Plugin.


The biggest plugin in space...