def init_from_data(self, data): path = ['static', 'media'] + fanout(self.sha256, (2, 2, 2)) + ['%s.%s' % (self.sha256, self.file_type)] self.file_path = os.path.join(*path) self.file_url = '/' + self.file_path real_path = self.full_file_path makedirs_exist_ok(os.path.dirname(real_path)) with open(real_path, 'wb') as outfile: outfile.write(data)
def init_from_data(self, data): path = ['static', 'media'] + fanout( self.sha256, (2, 2, 2)) + ['%s.%s' % (self.sha256, self.file_type)] self.file_path = os.path.join(*path) self.file_url = '/' + self.file_path real_path = self.full_file_path makedirs_exist_ok(os.path.dirname(real_path)) with open(real_path, 'wb') as outfile: outfile.write(data)
def _file_path_components(self): return ['static', 'media'] + fanout( self.sha256, (2, 2, 2)) + ['%s.%s' % (self.sha256, self.file_type)]