def _save(self, name, content): name = normalize_name(name) try: dbfile = DBFile.objects.get(file_name=name) except DBFile.DoesNotExist: dbfile = DBFile(file_name=name) raw_data = content.read() dbfile.size = len(raw_data) dbfile.data = raw_data # should probably do this in chunks dbfile.save() del raw_data return name
def _save(self, name, content): name = normalize_name(name) try: dbfile = DBFile.objects.get(file_name=name) except DBFile.DoesNotExist: dbfile = DBFile(file_name=name) raw_data = content.read() dbfile.size = len(raw_data) dbfile.data = raw_data dbfile.save() cache.set(name, dbfile, self.CACHE_TIMEOUT) del raw_data return name