def get(self, id=None): if id: self.grid_id = id if self.grid_id is None: return None try: if self.gridout is None: self.gridout = io.BytesIO(S3.get_file_s3(self.grid_id, self.collection_name)) return self.gridout except: return None
def get_file(sample_md5, collection): """ Get a file from GridFS (or S3 if that's what you've configured). :param sample_md5: The MD5 of the file to download. :type sample_md5: str :param collection: The collection to grab the file from. :type collection: str :returns: str """ # Workaround until pcap download uses pcap object if settings.FILE_DB == settings.GRIDFS: return get_file_gridfs(sample_md5, collection) elif settings.FILE_DB == settings.S3: objs = mongo_connector(collection) obj = objs.find_one({"md5": sample_md5}) oid = obj['filedata'] return get_file_s3(oid,collection)
def get_file(sample_md5, collection): """ Get a file from GridFS (or S3 if that's what you've configured). :param sample_md5: The MD5 of the file to download. :type sample_md5: str :param collection: The collection to grab the file from. :type collection: str :returns: str """ # Workaround until pcap download uses pcap object if settings.FILE_DB == settings.GRIDFS: return get_file_gridfs(sample_md5, collection) elif settings.FILE_DB == settings.S3: objs = mongo_connector(collection) obj = objs.find_one({"md5": sample_md5}) oid = obj['filedata'] return get_file_s3(oid, collection)