[CSHARP-1494] Add GridFs.DeleteByNameAsync(filename) to new GridFs Created: 05/Dec/15  Updated: 17/Oct/17  Resolved: 17/Oct/17

Status: Closed
Project: C# Driver
Component/s: GridFS
Affects Version/s: 2.1.1
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Christian Sleight [X] Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

This existed in previous legacy driver. Right now I am running a FindAsync by filename to find all files to delete.



 Comments   
Comment by Robert Stam [ 05/Dec/15 ]

The current GridFS spec does not support deleting a file by name. Mainly this is to avoid any confusion that might arise when there are multiple revisions of the same filename (what is the caller's intent: delete which revision? delete all revisions?).

With the current API the recommended way is to do what you are doing: use FindAsync to find all the revisions and delete them one by one. The code would be very similar to the example given for renaming all revisions of a filename:

http://mongodb.github.io/mongo-csharp-driver/2.1/reference/gridfs/deletingandrenamingfiles/#renaming-all-revisions-of-a-file

Generated at Wed Feb 07 21:39:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.