msc: upload_pictures() docs

rrr-marble 5 years ago
parent ea9c05dcc0
commit 5840126b6d

@ -11,5 +11,5 @@ DEST_SHRUNK = "image/"
DEST_ORIGINAL = "original/" DEST_ORIGINAL = "original/"
# upload interface credentials # upload interface credentials
CRED_USERNAME="changeme" CRED_USERNAME = "changeme"
CRED_PASSWORD="CHANGEME" CRED_PASSWORD = "CHANGEME"

@ -162,7 +162,7 @@ async def rate_picture(cookie: str, picture_id: int, mark: int):
@app.post( @app.post(
"/upload_pictures/", "/upload_pictures",
responses={ responses={
202: {"description": "Archive accepted into processing"}, 202: {"description": "Archive accepted into processing"},
401: {"description": "Authentication is required to access this resource"}, 401: {"description": "Authentication is required to access this resource"},
@ -174,10 +174,12 @@ async def upload_pictures(
credentials: HTTPBasicCredentials = Depends(security), credentials: HTTPBasicCredentials = Depends(security),
file: UploadFile = File(...), file: UploadFile = File(...),
): ):
"""Интерфейс для загрузки фотографий""" """Photo upload endpoint"""
"""Условно кладём в браузер zip с фотографиями и он их потихоньку ест. """
Доступ к этому интерфейсу, наверное, лучше ограничить паролем или как-нибудь ещё. Accepts photo in zip archives with any internal directory structure
Пока исходим из предположения, что только я буду загружать фотографии. Valid uploads yield 202 status message and process photos in the background
Non-zip archives yeild 415 error
Upload is restricted by basic HTTP login, configurable in config.py
""" """
# check authenticity # check authenticity
correct_username = compare_digest(credentials.username, CRED_USERNAME) correct_username = compare_digest(credentials.username, CRED_USERNAME)
@ -204,8 +206,8 @@ def unpack_pictures_zip(file: UploadFile, time):
""" """
Unpack and process zip archived photo Unpack and process zip archived photo
Extract pictures in the DATA_LOCATION/processing Extract pictures in the DATA_LOCATION/processing
#TODO: and feed them to util/import_photos.py and feed them to util/import_photos.py
#TODO: Walk the nested DATA_LOCATION/processing ourselves Walk the nested DATA_LOCATION/processing ourselves
Uses: DB_LOCATION, DATA_LOCATION Uses: DB_LOCATION, DATA_LOCATION
""" """
# we only call this function sporadically, so import here # we only call this function sporadically, so import here

Loading…
Cancel
Save