aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-10 12:04:13 +0300
committerBonfaceKilz2021-03-10 12:04:13 +0300
commitd31ccc82aa84432c6cfef1a0a2d8f34beee179cd (patch)
treea74ea92771666fa417ee09b1b0091f42207122fc /gn3/api
parent374d7bf253d29a910e8bbbbd6c9ea01394fb8e3f (diff)
downloadgenenetwork3-d31ccc82aa84432c6cfef1a0a2d8f34beee179cd.tar.gz
Add extra endpoint for when TOKEN isn't provided
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/general.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/gn3/api/general.py b/gn3/api/general.py
index d05d6f4..38e6154 100644
--- a/gn3/api/general.py
+++ b/gn3/api/general.py
@@ -11,12 +11,32 @@ from gn3.file_utils import extract_uploaded_file
general = Blueprint("general", __name__)
+@general.route("/metadata/upload/", methods=["POST"],
+ strict_slashes=False)
+def upload_metadata_with_no_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. Generate a TOKEN
+
+ """
+ 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=file_,
+ target_dir=current_app.config["TMPDIR"],
+ token=None)
+ if results.get("status") > 0:
+ status = 500
+ return jsonify(results), status
+
+
@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.
+TTL is set in the metadata file. If none is provided, the default is 1 week.
"""
file_ = request.files.get("file")