Add file checksum validation
This commit is contained in:
parent
7fd5f1bcd8
commit
07ec667483
|
@ -1,4 +1,3 @@
|
||||||
cryptography
|
cryptography
|
||||||
flask
|
flask
|
||||||
flask_sqlalchemy
|
flask_sqlalchemy
|
||||||
pytest
|
|
|
@ -83,6 +83,13 @@ def file_upload_content():
|
||||||
if not file:
|
if not file:
|
||||||
return jsonify({"error": "Invalid file data"}), 400
|
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)
|
file = upload_service.write_file(session_token, file.stream)
|
||||||
if isinstance(file, tuple):
|
if isinstance(file, tuple):
|
||||||
return file
|
return file
|
||||||
|
|
Loading…
Reference in New Issue