summaryrefslogtreecommitdiff
path: root/matweb/rest_api.py
diff options
context:
space:
mode:
Diffstat (limited to 'matweb/rest_api.py')
-rw-r--r--matweb/rest_api.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/matweb/rest_api.py b/matweb/rest_api.py
index d3d9d8f..ef1a55a 100644
--- a/matweb/rest_api.py
+++ b/matweb/rest_api.py
@@ -46,29 +46,31 @@ class APIUpload(Resource):
46 if parser is None: 46 if parser is None:
47 current_app.logger.error('Upload - Invalid mime type %s', mime) 47 current_app.logger.error('Upload - Invalid mime type %s', mime)
48 abort(415, message='The type %s is not supported' % mime) 48 abort(415, message='The type %s is not supported' % mime)
49 49 try:
50 meta = parser.get_meta() 50 if not parser.remove_all():
51 if not parser.remove_all(): 51 raise ValueError()
52 meta = parser.get_meta()
53 key, secret, meta_after, output_filename = utils.cleanup(parser, filepath,
54 current_app.config['UPLOAD_FOLDER'])
55 return utils.return_file_created_response(
56 utils.get_file_removal_max_age_sec(),
57 output_filename,
58 mime,
59 key,
60 secret,
61 meta,
62 meta_after,
63 url_for(
64 'api_bp.apidownload',
65 key=key,
66 secret=secret,
67 filename=output_filename,
68 _external=True
69 )
70 ), 201
71 except (ValueError, RuntimeError) as e:
52 current_app.logger.error('Upload - Cleaning failed with mime: %s', mime) 72 current_app.logger.error('Upload - Cleaning failed with mime: %s', mime)
53 abort(500, message='Unable to clean %s' % mime) 73 abort(400, message='Unable to clean %s' % mime)
54
55 key, secret, meta_after, output_filename = utils.cleanup(parser, filepath, current_app.config['UPLOAD_FOLDER'])
56 return utils.return_file_created_response(
57 utils.get_file_removal_max_age_sec(),
58 output_filename,
59 mime,
60 key,
61 secret,
62 meta,
63 meta_after,
64 url_for(
65 'api_bp.apidownload',
66 key=key,
67 secret=secret,
68 filename=output_filename,
69 _external=True
70 )
71 ), 201
72 74
73 75
74class APIDownload(Resource): 76class APIDownload(Resource):