upload endpoint #5
Merged
w2
merged 14 commits from w2/photovoter_backend:upload into main 4 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'w2/photovoter_backend:upload'
Deleting a branch is permanent. It CANNOT be undone. Continue?
/upload_pictures
Новый эндпоинт для загрузки фотографий.
Потребляет zip архивы с фотографиями, внутренняя структура директорий свободная.
Загрузка архива возвращает 202 "Accepted" статус и передаёт его на обработку отдельной функции. Возможна одновременная обработка нескольких архивов.
Загрузка недопустимого архива возвращает 415 "Unsupported Media Type".
Загрузка ограничена сочетанием имени пользователя и пароля, конфигурируемым в config.py; неверные сочетания возвращают 401 "Unauthorized"
fixes #2
uploadto upload endpoint 4 years agotasks.add_task(unpack_pictures_zip,file=file,time=datetime.utcnow().replace(microsecond=0).isoformat(),Windows doesn't support colons in path. Use
time.time()"OriginalImage": path.join(DEST_ORIGINAL, filename),"ResizedImage": path.join(dest_shrunk, filename),"OriginalImage": path.join(dest_original, filename),"DateTimeOriginal": exif["DateTimeOriginal"], # Q: normalize it?Ignore invalid images (no required exif data)
Протестировал на фотках с координатами. Всё работает. Для тестирования тут https://transfer.sh/W4P8gz/IMG_8403.zip
f5f04cde08to3e7ef811024 years agoIt works fine. Only major issue is image flipping which is probably connected to this row. Coordinates recalculation would improve usability too.
"testbox/photovoter.dblite" # Q: any allowances for this being not OUR database?)DATA_LOCATION = "/tmp/123"Add comment that
DATA_LOCATIONshould end with a slash liketest/. Else in Windows a path stored in a database looks like thistest\image/img.jpg. It could cause problems in a frontend.Better yet, we can just normalize it. Can be done right in the config.py (since we made it .py) but it's only used in a handful of places so let's not clutter it with code just yet.
Fixed now.
Some say Python on Windows will automatically handle forward slashes (/) properly.
You probably shouldn't mix and match DBs from different systems, tho. So, if upload to windows, serve from windows too.
"ResizedImage": path.join(DEST_SHRUNK, filename),"OriginalImage": path.join(DEST_ORIGINAL, filename),"DateTimeOriginal": exif["DateTimeOriginal"], # Q: normalize it?"GPSLatitude": exif["GPSLatitude"],Could we transform it to decimal form? See https://gis.stackexchange.com/questions/136925/how-to-parse-exif-gps-information-to-lat-lng-decimal-numbers

Now it looks like this
To convert it we should
dec_degree = 55 / 1 + 40 / 1 / 60 + 515 / 100 / 3600 = 55.66810(five decimal places are enough). General formula isdec_degree = degreesNumerator / degreesDenominator + minutesNumerator / minutesDenominator / 60 + secondsNumerator / secondsDenominator / 3600.Independent of this PR. (Should have done in in #4). I filed #7.
cloned.strip() # Q: may damage icc, do we allow that or use smh else?cloned.transform(resize="50%") # Q: what do we want here?I think width=1000px with preserved aspect ratio would be enough.
Independent of this PR. I filed #8.
Independent of this PR, i filed #9
Looks good to me 👍
2f967b584finto main 4 years agoReviewers
2f967b584f.