aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-02 11:08:05 +0300
committerBonfaceKilz2021-03-08 21:09:58 +0300
commit1bceba1b421c9f57095e1fa3cb6e872cec9ae4bb (patch)
tree174533bb62e4892ba54739ba99823dbcda7d0231 /gn3
parentd0347cecce5655caba96d330536a83279df28f0b (diff)
downloadgenenetwork3-1bceba1b421c9f57095e1fa3cb6e872cec9ae4bb.tar.gz
Use new extract_uploaded_file fn when uploading metadata
* gn3/api/general.py (upload_metadata): Update docstrings and update the use of "extract_uploaded_file" fn.
Diffstat (limited to 'gn3')
-rw-r--r--gn3/api/general.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/gn3/api/general.py b/gn3/api/general.py
index c1b6aa7..91a113c 100644
--- a/gn3/api/general.py
+++ b/gn3/api/general.py
@@ -11,20 +11,22 @@ from gn3.file_utils import extract_uploaded_file
general = Blueprint("general", __name__)
-@general.route("/metadata/upload", methods=["POST"])
-def upload_metadata():
- """Extract uploaded file to gn3 temporary directory; and if successful return
-a TOKEN to the user
+@general.route("/metadata/upload/<token>", methods=["POST"],
+ strict_slashes=False)
+def upload_metadata(token):
+ """Extract uploaded file to a some TMPDIR/TOKEN/ with a TTL(Time To Live). The
+TTL is set in the metadata file. If none is provided, the default is 1
+week. If a TOKEN is not provided, generate a token for the new user.
"""
file_ = request.files.get("file")
if not file_:
return jsonify(status=128, error="Please provide a file!"), 400
-
status = 201
results = extract_uploaded_file(
- gzipped_file=request.files["file"],
- target_dir=current_app.config["APP_DEFAULTS"].get("TMPDIR"))
+ gzipped_file=file_,
+ target_dir=current_app.config["APP_DEFAULTS"].get("TMPDIR"),
+ token=token)
if results.get("status") > 0:
status = 500
return jsonify(results), status