diff options
Diffstat (limited to 'matweb')
| -rw-r--r-- | matweb/rest_api.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/matweb/rest_api.py b/matweb/rest_api.py index 72da1cd..1e7f9fd 100644 --- a/matweb/rest_api.py +++ b/matweb/rest_api.py | |||
| @@ -92,22 +92,27 @@ class APIClean(Resource): | |||
| 92 | @swag_from('./oas/remove_metadata.yml') | 92 | @swag_from('./oas/remove_metadata.yml') |
| 93 | def post(self): | 93 | def post(self): |
| 94 | if 'file' not in request.files: | 94 | if 'file' not in request.files: |
| 95 | current_app.logger.error('Clean - No file part') | ||
| 95 | abort(400, message='No file part') | 96 | abort(400, message='No file part') |
| 96 | 97 | ||
| 97 | uploaded_file = request.files['file'] | 98 | uploaded_file = request.files['file'] |
| 98 | if not uploaded_file.filename: | 99 | if not uploaded_file.filename: |
| 100 | current_app.logger.error('Clean - No selected `file`') | ||
| 99 | abort(400, message='No selected `file`') | 101 | abort(400, message='No selected `file`') |
| 100 | try: | 102 | try: |
| 101 | filename, filepath = utils.save_file(uploaded_file, current_app.config['UPLOAD_FOLDER']) | 103 | filename, filepath = utils.save_file(uploaded_file, current_app.config['UPLOAD_FOLDER']) |
| 102 | except ValueError: | 104 | except ValueError: |
| 105 | current_app.logger.error('Clean - Invalid Filename') | ||
| 103 | abort(400, message='Invalid Filename') | 106 | abort(400, message='Invalid Filename') |
| 104 | 107 | ||
| 105 | parser, mime = utils.get_file_parser(filepath) | 108 | parser, mime = utils.get_file_parser(filepath) |
| 106 | 109 | ||
| 107 | if parser is None: | 110 | if parser is None: |
| 111 | current_app.logger.error('Clean - The type %s is not supported', mime) | ||
| 108 | abort(415, message='The type %s is not supported' % mime) | 112 | abort(415, message='The type %s is not supported' % mime) |
| 109 | 113 | ||
| 110 | if parser.remove_all() is not True: | 114 | if parser.remove_all() is not True: |
| 115 | current_app.logger.error('Clean - Unable to clean %s', mime) | ||
| 111 | abort(500, message='Unable to clean %s' % mime) | 116 | abort(500, message='Unable to clean %s' % mime) |
| 112 | 117 | ||
| 113 | _, _, _, output_filename = utils.cleanup(parser, filepath, current_app.config['UPLOAD_FOLDER']) | 118 | _, _, _, output_filename = utils.cleanup(parser, filepath, current_app.config['UPLOAD_FOLDER']) |
