msc: upload_pictures() docs

main^2
rrr-marble 4 years ago
parent 4b0b6ab9cc
commit 3e35188739

@ -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"

@ -188,7 +188,7 @@ async def photo_points():
for point in points for point in points
] ]
@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"},
@ -200,10 +200,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)
@ -230,8 +232,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