Search code examples
c#mongodbmongodb-.net-drivergridfs

What happened to GridFS?


I'm just porting an application over to use the new version 2.0 MongoDB C# driver. I'm struggling replacing the parts that use the GridFS as I wasn't able to find any news or documentation regarding GridFS. Since it's class is marked as deprecated: how to use this in the latest version?

Sample code that's failing:

// read and store local file in database
using (var stream = new FileStream(filePath, FileMode.Open))
{
  // generate unique file name and upload it
  var remoteFile = DbCurrent.GridFS.Upload(stream, Guid.NewGuid().ToString());
  // save file id
  _currentAttachment.FileId = remoteFile.Id.AsObjectId;
}

Solution

  • Apparently, GridFS is not available with the async 2.0.0 driver yet, see CSHARP-1191. It appears they're currently working on it.