def step_impl(context): headers = {"token": context.token} image_file = {'file_name.jpg': Constants.IMAGE_FILE_BINARY_BMP} old_file_name_without_extention = file_info.get_file_name(context.image_name) result = requests.put("{}/files/{}/{}".format(Url.DOMAIN_ADDRESS, context.storage_name, old_file_name_without_extention), files=image_file, headers=headers) print(result) context.replace_result = result
def execute(self): super().string.size(self.instance.file_name, 2, 500) super().string.size(self.instance.storage_name, 2, 20) super().validate() super().custom.register(self.instance.file_name, FileNameIsInvalid()) file_id = file_info.get_file_name(self.instance.file_name) super().custom.register(file_id, FileIdNotExist(self.instance.storage_name)) super().validate()
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 execute(self): super().string.size(self.instance.file_name, 3, 100) super().string.size(self.instance.storage_name, 2, 20) super().validate() if not file_info.get_file_name(self.instance.file_name): super().custom.manual(ApkErrorCodes.APK_NAME_OR_EXTENSION_NOT_EXIST) super().custom.register(self.instance.file_name, ApkFileNameNotExist(self.instance.storage_name)) super().validate()
def execute(self): super().string.size(self.instance.old_file_name, 2, 500) super().string.size(self.instance.storage_name, 2, 20) super().string.size(self.instance.new_file["file_name"], 2, 500) super().validate() if not self.instance.new_file["file_content"]: super().custom.manual(FileErrorCodes.RESOURCE_CONTENT_IS_EMPTY) super().custom.register(self.instance.old_file_name, FileNameIsInvalid()) super().custom.register(self.instance.new_file["file_name"], FileNameIsInvalid()) super().validate() file_id = file_info.get_file_name(self.instance.old_file_name) super().custom.register(file_id, FileIdNotExist(self.instance.storage_name)) super().validate()
def execute(self): super().string.size(self.instance.storage_name, 2, 20) super().string.size(self.instance.file["file_name"], 2, 500) super().string.size(self.instance.package_name, 2, 150) super().string.size(self.instance.version, 2, 50) super().integer.positive(self.instance.version_id, include_zero=False) super().validate() if not self.instance.file["file_content"]: super().custom.manual(ApkErrorCodes.RESOURCE_CONTENT_IS_EMPTY) if not file_info.get_file_name(self.instance.file["file_name"]) or not file_info.get_extension( self.instance.file["file_name"]): super().custom.manual(ApkErrorCodes.APK_NAME_OR_EXTENSION_NOT_EXIST, data=self.instance.file["file_name"]) super().custom.register(self.instance.file["file_name"], ApkFileExtensionNotExist()) super().custom.register("{}_{}.{}".format(self.instance.package_name, self.instance.version, file_info.get_extension(self.instance.file["file_name"])), ApkFileNameExist(self.instance.storage_name)) super().custom.register(self.instance.version_id, ApkVersionIdExist(self.instance.storage_name)) super().validate()
def validate(self, file_name): if "." not in file_name: super().custom.manual(FileErrorCodes.FILE_NAME_IS_INVALID, data=file_name) else: if not file_info.get_file_name(file_name) or not file_info.get_extension(file_name): super().custom.manual(FileErrorCodes.FILE_NAME_OR_EXTENSION_NOT_EXIST, file_name)
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)