I have an image with the following metadata:
> db.fs.files.find().pretty()
{
"_id" : ObjectId("4576874577342672346"),
"chunkSize" : 262144,
"user_name" : "my name",
"filename" : "image.jpg",
"length" : 7103,
"uploadDate" : ISODate("2014-01-23T13:31:48.155Z"),
"user_email" : "email@email.com",
"md5" : "1234567890"
}
>
I want to delete the image from Python (PyMongo).
The documentation on delete()
seems to stipulate that the only accepted parameter in the delete()
function is the file_id
:
http://api.mongodb.org/python/current/api/gridfs/#gridfs.GridFS.delete
Programmatically, I have the following values available that can be matched in the files metadata:
- user_name
- filename
- user_email
How do I either:
- Get the
file_id
(through use of the above values if necessary) or - Delete the file based on metadata fields other than
file_id
?
Additionally, I am only currently testing with single chunk files, if interacting with larger files in the future will deleting by file_id
or other metadata remove all associated chunks as well?