def save_bucket(self,file_chunks,file_name,file_property):
     mongo_helper=MongodbHelper(self.host,self.port)
     file_bucket_fs=mongo_helper.pub_file_bucket(self.db,self.collection,file_name,file_property)
     for chunk in file_chunks:
         file_bucket_fs.write(chunk)
     file_bucket_fs.close()
     return file_bucket_fs._id
Exemple #2
0
 def save_content(self, content, file_name, file_property):
     mongo_helper = MongodbHelper(self.host, self.port)
     file_bucket_fs = mongo_helper.pub_file_bucket(self.db, self.collection,
                                                   file_name, file_property)
     file_bucket_fs.write(content.encode(encoding="utf-8"))
     file_bucket_fs.close()
     return file_bucket_fs._id
Exemple #3
0
 def copy_bucket(self, grid_out):
     mongo_helper = MongodbHelper(self.host, self.port)
     file_bucket_fs = mongo_helper.pub_file_bucket(self.db, self.collection,
                                                   grid_out.name,
                                                   grid_out.metadata)
     while True:
         chunk = grid_out.read(size=1024 * 1024 * 10)
         if chunk:
             file_bucket_fs.write(chunk)
         else:
             break
     file_bucket_fs.close()
     return file_bucket_fs._id