feat(api): changed mobile sign endpoint
This commit is contained in:
parent
26d2131bae
commit
cd44f2735d
2 changed files with 11 additions and 9 deletions
|
|
@ -903,7 +903,7 @@ def get_general_stats():
|
|||
return {"data": {"sessions:": sessions.count_all()}}
|
||||
|
||||
|
||||
@app.route('/mobile/urls', methods=['POST'])
|
||||
def mobile_signe(context):
|
||||
@app.route('/{projectId}/mobile/{sessionId}/urls', methods=['POST'])
|
||||
def mobile_signe(projectId, sessionId, context):
|
||||
data = app.current_request.json_body
|
||||
return {"data": mobile.sign_urls(data["URL"])}
|
||||
return {"data": mobile.sign_keys(project_id=projectId, session_id=sessionId, keys=data["keys"])}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
from chalicelib.utils import s3, s3urls
|
||||
from chalicelib.core import projects
|
||||
from chalicelib.utils import s3
|
||||
from chalicelib.utils.helper import environ
|
||||
|
||||
|
||||
def sign_urls(urls):
|
||||
def sign_keys(project_id, session_id, keys):
|
||||
result = []
|
||||
for u in urls:
|
||||
e = s3urls.parse_url(u)
|
||||
result.append(s3.get_presigned_url_for_sharing(bucket=e["bucket"],
|
||||
key=e["key"],
|
||||
project_key = projects.get_project_key(project_id)
|
||||
for k in keys:
|
||||
result.append(s3.get_presigned_url_for_sharing(bucket=environ["iosBucket"],
|
||||
key=f"{project_key}/{session_id}/{k}",
|
||||
expires_in=10 * 60))
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue