예제 #1
0
 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()
예제 #2
0
 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
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 def execute(self):
     return File.path_exist(self.storage_name, self.path)
예제 #6
0
 def execute(self):
     file = File(self.storage_name)
     file.path = self.path
     file.remove_by_path()
예제 #7
0
 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)
예제 #8
0
 def execute(self):
     file = File(self.storage_name)
     file.persisted_file_name = self.file_name
     file.remove_by_path()