feat(phase1): add image storage utilities

- 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
This commit is contained in:
2026-04-20 21:57:26 +03:00
parent 39fab336ba
commit ea49cd6e4a
4487 changed files with 1305959 additions and 4 deletions

View File

@@ -0,0 +1,63 @@
Metadata-Version: 2.4
Name: pydantic-settings
Version: 2.14.0
Summary: Settings management using Pydantic
Project-URL: Homepage, https://github.com/pydantic/pydantic-settings
Project-URL: Funding, https://github.com/sponsors/samuelcolvin
Project-URL: Source, https://github.com/pydantic/pydantic-settings
Project-URL: Changelog, https://github.com/pydantic/pydantic-settings/releases
Project-URL: Documentation, https://docs.pydantic.dev/dev-v2/concepts/pydantic_settings/
Author-email: Samuel Colvin <s@muelcolvin.com>, Eric Jolibois <em.jolibois@gmail.com>, Hasan Ramezani <hasan.r67@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Environment :: MacOS X
Classifier: Framework :: Pydantic
Classifier: Framework :: Pydantic :: 2
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: pydantic>=2.7.0
Requires-Dist: python-dotenv>=0.21.0
Requires-Dist: typing-inspection>=0.4.0
Provides-Extra: aws-secrets-manager
Requires-Dist: boto3>=1.35.0; extra == 'aws-secrets-manager'
Requires-Dist: types-boto3[secretsmanager]; extra == 'aws-secrets-manager'
Provides-Extra: azure-key-vault
Requires-Dist: azure-identity>=1.16.0; extra == 'azure-key-vault'
Requires-Dist: azure-keyvault-secrets>=4.8.0; extra == 'azure-key-vault'
Provides-Extra: gcp-secret-manager
Requires-Dist: google-cloud-secret-manager>=2.23.1; extra == 'gcp-secret-manager'
Provides-Extra: toml
Requires-Dist: tomli>=2.0.1; extra == 'toml'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0.1; extra == 'yaml'
Description-Content-Type: text/markdown
# pydantic-settings
[![CI](https://github.com/pydantic/pydantic-settings/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/pydantic/pydantic-settings/actions/workflows/ci.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/pydantic/pydantic-settings/branch/main/graph/badge.svg)](https://codecov.io/gh/pydantic/pydantic-settings)
[![pypi](https://img.shields.io/pypi/v/pydantic-settings.svg)](https://pypi.python.org/pypi/pydantic-settings)
[![license](https://img.shields.io/github/license/pydantic/pydantic-settings.svg)](https://github.com/pydantic/pydantic-settings/blob/main/LICENSE)
[![downloads](https://static.pepy.tech/badge/pydantic-settings/month)](https://pepy.tech/project/pydantic-settings)
[![versions](https://img.shields.io/pypi/pyversions/pydantic-settings.svg)](https://github.com/pydantic/pydantic-settings)
Settings management using Pydantic.
See [documentation](https://docs.pydantic.dev/latest/concepts/pydantic_settings/) for more details.

View File

@@ -0,0 +1,51 @@
pydantic_settings-2.14.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
pydantic_settings-2.14.0.dist-info/METADATA,sha256=6aNGYxqx3yKp7Tpd7LZU9WFX3RABWvegYlngmx0l5KA,3395
pydantic_settings-2.14.0.dist-info/RECORD,,
pydantic_settings-2.14.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
pydantic_settings-2.14.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
pydantic_settings-2.14.0.dist-info/licenses/LICENSE,sha256=6zVadT4CA0bTPYO_l2kTW4n8YQVorFMaAcKVvO5_2Zg,1103
pydantic_settings/__init__.py,sha256=_2aYjmOukI0KsXbkdAsnnNCTcwxDl8qSi5X_djGJ9vc,1707
pydantic_settings/__pycache__/__init__.cpython-312.pyc,,
pydantic_settings/__pycache__/exceptions.cpython-312.pyc,,
pydantic_settings/__pycache__/main.cpython-312.pyc,,
pydantic_settings/__pycache__/utils.cpython-312.pyc,,
pydantic_settings/__pycache__/version.cpython-312.pyc,,
pydantic_settings/exceptions.py,sha256=SHLrIBHeFltPMc8abiQxw-MGqEadlYI-VdLELiZtWPU,97
pydantic_settings/main.py,sha256=qc97-63zTOtIPmfFUMACwb1g8NOSj6OR4AedoXywKKQ,43610
pydantic_settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
pydantic_settings/sources/__init__.py,sha256=8Mhev9QzMDfJ1dBlLJ1j3_PXEaD1ggcxrYp0gD3kJdo,2350
pydantic_settings/sources/__pycache__/__init__.cpython-312.pyc,,
pydantic_settings/sources/__pycache__/base.cpython-312.pyc,,
pydantic_settings/sources/__pycache__/types.cpython-312.pyc,,
pydantic_settings/sources/__pycache__/utils.cpython-312.pyc,,
pydantic_settings/sources/base.py,sha256=yqdhh1Pc1w1TilCsvQCNmVC6IQi9gqEUkoTF796I_tQ,23664
pydantic_settings/sources/providers/__init__.py,sha256=KfYerDF3UC-0aLPc29KLuIYomPxYksryLFSPBVrZXSg,1281
pydantic_settings/sources/providers/__pycache__/__init__.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/aws.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/azure.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/cli.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/dotenv.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/env.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/gcp.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/json.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/nested_secrets.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/pyproject.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/secrets.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/toml.cpython-312.pyc,,
pydantic_settings/sources/providers/__pycache__/yaml.cpython-312.pyc,,
pydantic_settings/sources/providers/aws.py,sha256=lb7HxyPKCCZajUWlwglKJcqb9R4n8aeZRQf-rbIHp5o,2730
pydantic_settings/sources/providers/azure.py,sha256=Qhf7IR7p0177NBwiLih6vTiMwWatgpP5EfQu2EI3KiA,5584
pydantic_settings/sources/providers/cli.py,sha256=6yIsOPOXp7cA1Hq0zFs__mskFPiBK0jfq5_vYs-ijVQ,74463
pydantic_settings/sources/providers/dotenv.py,sha256=YX9VvhNXQ4HLvIQAYncAXHYsSxAmAaszyN83ZcCe09E,7335
pydantic_settings/sources/providers/env.py,sha256=SFg6AaeVgSawaPeQg3QwxOjXu5xtdoet7aau38S_Ez0,13510
pydantic_settings/sources/providers/gcp.py,sha256=Y_5sa0ig-zN6MwVwRzAABNj87bN9nDJsLhXGCBU94aE,9962
pydantic_settings/sources/providers/json.py,sha256=H0BpGTSkS0V9H59jr0ZTp_an2kLCSfef0TqwJuHY0iM,1492
pydantic_settings/sources/providers/nested_secrets.py,sha256=9vpesWyl4fssfbcalPqjjoiCr1hvi1ikexFwH2UqgPo,6622
pydantic_settings/sources/providers/pyproject.py,sha256=zSQsV3-jtZhiLm3YlrlYoE2__tZBazp0KjQyKLNyLr0,2052
pydantic_settings/sources/providers/secrets.py,sha256=k5CFjS6ImQH4mP_bTaVJ3Iq8RF_ul0l9FEUPJUY8YLk,4470
pydantic_settings/sources/providers/toml.py,sha256=xySqX4H--8E7yWq49SXzAK-BDPMaW-evfGCgQ3Bsq9g,1883
pydantic_settings/sources/providers/yaml.py,sha256=pCZ-YDsjVyQIePEIqoPplIVtL9Vrr6gNAvC7JaFaR2w,4777
pydantic_settings/sources/types.py,sha256=jN72c7TQILwj53LmcXozcL9gnFVVbJPRaE_7r3WciSY,1980
pydantic_settings/sources/utils.py,sha256=hTWqE3p3A0kBQtkhGXN4bhe7ir2RQtL0em9tnAyvhJI,12290
pydantic_settings/utils.py,sha256=8jXay93JWt26z12XORLcgGMPCndKVDJVPWtQNt4JZ3Q,1353
pydantic_settings/version.py,sha256=xEXRwMzoiXMgu1HnSPy4zkJ-bHJ7aipcWe3R1EwSFuQ,19

View File

@@ -0,0 +1,4 @@
Wheel-Version: 1.0
Generator: hatchling 1.29.0
Root-Is-Purelib: true
Tag: py3-none-any

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2022 Samuel Colvin and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.