Rearrange functions' order in `monkey_island/cc/resources/pba_file_upload.py` to follow stepdown rule

This commit is contained in:
Shreya 2021-04-26 15:18:26 +05:30
parent 4f94e9de74
commit 9b38303346
1 changed files with 18 additions and 18 deletions

View File

@ -58,6 +58,24 @@ class FileUpload(flask_restful.Resource):
response = Response(response=filename, status=200, mimetype="text/plain") response = Response(response=filename, status=200, mimetype="text/plain")
return response return response
@staticmethod
def upload_pba_file(request_, is_linux=True):
"""
Uploads PBA file to island's file system
:param request_: Request object containing PBA file
:param is_linux: Boolean indicating if this file is for windows or for linux
:return: filename string
"""
filename = secure_filename(request_.files["filepond"].filename)
file_path = (
Path(env_singleton.env.get_config().data_dir_abs_path).joinpath(filename).absolute()
)
request_.files["filepond"].save(str(file_path))
ConfigService.set_config_value(
(PBA_LINUX_FILENAME_PATH if is_linux else PBA_WINDOWS_FILENAME_PATH), filename
)
return filename
@jwt_required @jwt_required
def delete(self, file_type): def delete(self, file_type):
""" """
@ -76,24 +94,6 @@ class FileUpload(flask_restful.Resource):
return {} return {}
@staticmethod
def upload_pba_file(request_, is_linux=True):
"""
Uploads PBA file to island's file system
:param request_: Request object containing PBA file
:param is_linux: Boolean indicating if this file is for windows or for linux
:return: filename string
"""
filename = secure_filename(request_.files["filepond"].filename)
file_path = (
Path(env_singleton.env.get_config().data_dir_abs_path).joinpath(filename).absolute()
)
request_.files["filepond"].save(str(file_path))
ConfigService.set_config_value(
(PBA_LINUX_FILENAME_PATH if is_linux else PBA_WINDOWS_FILENAME_PATH), filename
)
return filename
@staticmethod @staticmethod
def _delete_file(file_path): def _delete_file(file_path):
try: try: