def create_directory(self, name): name = STORAGE.get_valid_name(name) tmpfile = os.path.join(name, '.tmp') path = os.path.join(self.path, tmpfile) STORAGE.save(path, ContentFile('')) STORAGE.delete(path)
def upload_file(self, filedata): filename = STORAGE.get_valid_name(filedata.name) filepath = os.path.join(self.path, filename) signals.filemanager_pre_upload.send(sender=self.__class__, filename=filename, path=self.path, filepath=filepath) STORAGE.save(filepath, filedata) signals.filemanager_post_upload.send(sender=self.__class__, filename=filename, path=self.path, filepath=filepath) return filename
def upload_file(self, filedata): filename = STORAGE.get_valid_name(filedata.name) filename, ext = os.path.splitext(filename) filename = slugify(re.sub("\d+", "", filename)) + ext filepath = os.path.join(self.path, filename) signals.filemanager_pre_upload.send(sender=self.__class__, filename=filename, path=self.path, filepath=filepath) STORAGE.save(filepath, filedata) signals.filemanager_post_upload.send(sender=self.__class__, filename=filename, path=self.path, filepath=filepath) return filename