Add file checksum validation
This commit is contained in:
parent
7fd5f1bcd8
commit
07ec667483
|
@ -1,4 +1,3 @@
|
|||
cryptography
|
||||
flask
|
||||
flask_sqlalchemy
|
||||
pytest
|
|
@ -83,6 +83,13 @@ def file_upload_content():
|
|||
if not file:
|
||||
return jsonify({"error": "Invalid file data"}), 400
|
||||
|
||||
file_sum = request.headers.get("File-Checksum")
|
||||
if not file_sum:
|
||||
return jsonify({"error": "No file checksum provided"}), 400
|
||||
|
||||
if file_sum != utils.get_hash(file.stream):
|
||||
return jsonify({"error": "File checksum mismatch"}), 400
|
||||
|
||||
file = upload_service.write_file(session_token, file.stream)
|
||||
if isinstance(file, tuple):
|
||||
return file
|
||||
|
|
Loading…
Reference in New Issue