def execute(self): file_id = file_info.get_file_name(self.old_file_name) file = File(self.storage_name) file._id = file_id file.persisted_file_name = self.old_file_name file.original_file_name = self.new_file["file_name"] file.content = self.new_file["file_content"] file.replace()
def get_by_id(self, id): from pystatic.domain.aggregates.file.model.file import File result = self._collection.reader.get(ObjectId(id)) file = File(result["info"]["storage_name"]) file._id = str(result["info"]["_id"]) file.content = result["binary_data"] file.original_file_name = result["info"]["original_file_name"] file.persisted_file_name = result["info"]["persisted_file_name"] file.path = result["info"]["path"] return file
def execute(self): file = File(self.storage_name) file.original_file_name = self.file["file_name"] file.content = self.file["file_content"] file.create() return FileUploadDetail.create_from_file(file)
def validate(self, file_id): file_exist = File.id_exists(self.storage_name, file_id) if not file_exist: super().custom.manual(FileErrorCodes.FILE_ID_NOT_EXIST, data=file_id)
def execute(self): return File.path_exist(self.storage_name, self.path)
def execute(self): file = File(self.storage_name) file.path = self.path file.remove_by_path()
def execute(self): file_id = file_info.get_file_name(self.file_name) file = File.get_by_id(self.storage_name, file_id) return FileDownloadDetail.create_from_file(file)
def execute(self): file = File(self.storage_name) file.persisted_file_name = self.file_name file.remove_by_path()