title: How to delete an image file from GridFS by file metadata?
body: <p>I have an image with the following metadata:</p>
  
  <pre><code>&gt; 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"
  }
  &gt;
  </code></pre>
  
  <p>I want to delete the image from Python (PyMongo).  </p>
  
  <p>The documentation on <code>delete()</code> seems to stipulate that the only accepted parameter in the <code>delete()</code> function is the <code>file_id</code>:</p>
  
  <p><a href="http://api.mongodb.org/python/current/api/gridfs/#gridfs.GridFS.delete" rel="nofollow">http://api.mongodb.org/python/current/api/gridfs/#gridfs.GridFS.delete</a></p>
  
  <p>Programmatically, I have the following values available that can be matched in the files metadata:</p>
  
  <ul>
  <li>user_name  </li>
  <li>filename  </li>
  <li>user_email  </li>
  </ul>
  
  <p>How do I either:</p>
  
  <ul>
  <li>Get the <code>file_id</code> (through use of the above values if necessary) or  </li>
  <li>Delete the file based on metadata fields other than <code>file_id</code>?</li>
  </ul>
  
  <p>Additionally, I am only currently testing with single chunk files, if interacting with larger files in the future will deleting by <code>file_id</code> or other metadata remove all associated chunks as well?</p>