title: Handling file in mongodb with gridfs
body: <p>Handeling file in mongodb with gridfs</p>
  
  <p>I have the questions below which i try to find the answer more than a week and can't find anything interesting as answer in the net:</p>
  
  <p>1) is it possible to insert via gridfs 2 differents files in the same mongofile request into mongo database? Can the files have the same and <code>uniq files_id</code></p>
  
  <p>2) I have user collection and each user have one or many files uploded into mongodb. Is it possible to make a link between users and file? I would like to know which file belongs to each user.</p>
  
  <p>3) So is it possible to have file's metadata (fs.files by default) in the user collection. For exemple something which will look like:</p>
  
  <pre><code>{  
     _id:112,
     Firstname:“Mickael”,
     Lasttname:“Jackson”,
     Files:[  
        {  
           _id:5910e57f24f3f7047494720c 
           "filename":"File1",
           "chunkSize":NumberInt(261120),
           "uploadDate":ISODate("2014-04-13T11:32:33.557Z"),
           "md5":"7b762939321e146569b07f72c62cca4f",
           "length":NumberInt(646)
        },
        {  
           _id:1841e57f24f3f7047494720b 
           "filename":"File2",
           "chunkSize":NumberInt(261120),
           "uploadDate":ISODate("2014-04-13T11:32:33.557Z"),
           "md5":"7b762939321e146569b07f72c62cca4f",
           "length":NumberInt(646)
        }
     ]
  }
  </code></pre>
  
  <p>Thank's in advance for your answer.</p>