GridFS file download, C# driver

I have a c# .net core project where I am trying to download a file which I have stored in GridFS. The upload works fine and using 3T studio I can access the files but any of the download commands throw an exception

var bucket = new GridFSBucket(_context.Database);  
var bytes = bucket.DownloadAsBytesByName("b7be1813-589a-4a0b-b720-70f9efd165aa");

The exception thrown is:

Command find failed: Error=2 {“Errors”:[“The index path corresponding to the specified order-by item is excluded.”]

I don’t understand what is wrong here, I used the driver to create the GridFS bucket initially so the indexes should be correct, I don’t know what it would be trying to order by which would cause this issue. No matter which download command I use they all fail with the same erro

Any help appreciated

Hi @Jon_Howell, welcome!

It’s been a while since you posted this question, have you found a solution?

Is there more information on the exception ? i.e. which class is throwing the exception.

Could you also provide the following information:

  • MongoDB server version
  • MongoDB .NET/C# driver version