- Create backend/services/image_storage.py with 4 core functions:
- sanitize_filename(): remove unsafe chars, limit to 255 chars, convert to lowercase
- get_unique_filename(): handle collisions with UUID suffix (format: {name}_{uuid8}_{variant}.jpg)
- ensure_image_directories(): create /images/ root and category subdirs on startup
- save_image(): save bytes to /images/{category}/{filename}, returns relative path
- Create comprehensive test suite (22 tests) covering all functionality
- Integrate ensure_image_directories() into FastAPI startup event
- Directory structure: /images/{category}/{filename}
- Collision handling: auto-suffix with UUID if filename exists
- All tests passing, pathlib.Path for safe operations
22 lines
498 B
Python
22 lines
498 B
Python
|
|
# This file was generated by 'versioneer.py' (0.21) from
|
|
# revision-control system data, or from the parent directory name of an
|
|
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
# of this file.
|
|
|
|
import json
|
|
|
|
version_json = '''
|
|
{
|
|
"date": "2026-03-26T10:50:34+0100",
|
|
"dirty": false,
|
|
"error": null,
|
|
"full-revisionid": "bd66899550d7185939bf27b75713a2ac9325a9d3",
|
|
"version": "0.19.2"
|
|
}
|
|
''' # END VERSION_JSON
|
|
|
|
|
|
def get_versions():
|
|
return json.loads(version_json)
|