summaryrefslogtreecommitdiff
path: root/matweb
diff options
context:
space:
mode:
Diffstat (limited to 'matweb')
-rw-r--r--matweb/rest_api.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/matweb/rest_api.py b/matweb/rest_api.py
index 48dcc10..5784bec 100644
--- a/matweb/rest_api.py
+++ b/matweb/rest_api.py
@@ -7,7 +7,7 @@ from uuid import uuid4
7 7
8from flask import after_this_request, send_from_directory, Blueprint, current_app 8from flask import after_this_request, send_from_directory, Blueprint, current_app
9from flask_restful import Resource, reqparse, abort, request, url_for, Api 9from flask_restful import Resource, reqparse, abort, request, url_for, Api
10from cerberus import Validator 10from cerberus import Validator, DocumentError
11from werkzeug.datastructures import FileStorage 11from werkzeug.datastructures import FileStorage
12from flasgger import swag_from 12from flasgger import swag_from
13 13
@@ -157,9 +157,13 @@ class APIBulkDownloadCreator(Resource):
157 if not data: 157 if not data:
158 abort(400, message="Post Body Required") 158 abort(400, message="Post Body Required")
159 current_app.logger.error('BulkDownload - Missing Post Body') 159 current_app.logger.error('BulkDownload - Missing Post Body')
160 if not self.v.validate(data): 160 try:
161 current_app.logger.error('BulkDownload - Missing Post Body: %s', str(self.v.errors)) 161 if not self.v.validate(data):
162 abort(400, message=self.v.errors) 162 current_app.logger.error('BulkDownload - Missing Post Body: %s', str(self.v.errors))
163 abort(400, message=self.v.errors)
164 except DocumentError as e:
165 abort(400, message="Invalid Post Body")
166 current_app.logger.error('BulkDownload - Invalid Post Body: %s', str(e))
163 # prevent the zip file from being overwritten 167 # prevent the zip file from being overwritten
164 zip_filename = 'files.' + str(uuid4()) + '.zip' 168 zip_filename = 'files.' + str(uuid4()) + '.zip'
165 zip_path = os.path.join(current_app.config['UPLOAD_FOLDER'], zip_filename) 169 zip_path = os.path.join(current_app.config['UPLOAD_FOLDER'], zip_filename)