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,69 @@
Authors
=======
* Marc Schlaich - https://github.com/schlamar (\http://www.schlamar.org)
* Rick van Hattem - http://wol.ph
* Buck Evan - https://github.com/bukzor
* Eric Larson - http://larsoner.com
* Marc Abramowitz - \http://marc-abramowitz.com
* Thomas Kluyver - https://github.com/takluyver
* Guillaume Ayoub - http://www.yabz.fr
* Federico Ceratto - \http://firelet.net
* Josh Kalderimis - \http://blog.cookiestack.com
* Ionel Cristian Mărieș - https://blog.ionelmc.ro
* Christian Ledermann - https://github.com/cleder
* Alec Nikolas Reiter - https://github.com/justanr
* Patrick Lannigan - https://github.com/plannigan
* David Szotten - https://github.com/davidszotten
* Michael Elovskikh - https://github.com/wronglink
* Saurabh Kumar - https://github.com/theskumar
* Michael Elovskikh - https://github.com/wronglink
* Daniel Hahler - https://github.com/blueyed (\https://daniel.hahler.de)
* Florian Bruhin - http://www.the-compiler.org
* Zoltan Kozma - https://github.com/kozmaz87
* Francis Niu - https://flniu.github.io
* Jannis Leidel - https://github.com/jezdez
* Ryan Hiebert - http://ryanhiebert.com/
* Terence Honles - https://github.com/terencehonles
* Jeremy Bowman - https://github.com/jmbowman
* Samuel Giffard - https://github.com/Mulugruntz
* Семён Марьясин - https://github.com/MarSoft
* Alexander Shadchin - https://github.com/shadchin
* Thomas Grainger - https://graingert.co.uk
* Juanjo Bazán - https://github.com/xuanxu
* Andrew Murray - https://github.com/radarhere
* Ned Batchelder - https://nedbatchelder.com/
* Albert Tugushev - https://github.com/atugushev
* Martín Gaitán - https://github.com/mgaitan
* Hugo van Kemenade - https://github.com/hugovk
* Michael Manganiello - https://github.com/adamantike
* Anders Hovmöller - https://github.com/boxed
* Zac Hatfield-Dodds - https://zhd.dev
* Mateus Berardo de Souza Terra - https://github.com/MatTerra
* Ganden Schaffner - https://github.com/gschaffner
* Michał Górny - https://github.com/mgorny
* Bernát Gábor - https://github.com/gaborbernat
* Pamela McA'Nulty - https://github.com/PamelaM
* Christian Riedel - https://github.com/Cielquan
* Chris Sreesangkom - https://github.com/csreesan
* Sorin Sbarnea - https://github.com/ssbarnea
* Brian Rutledge - https://github.com/bhrutledge
* Danilo Šegan - https://github.com/dsegan
* Michał Bielawski - https://github.com/D3X
* Zac Hatfield-Dodds - https://github.com/Zac-HD
* Ben Greiner - https://github.com/bnavigator
* Delgan - https://github.com/Delgan
* Andre Brisco - https://github.com/abrisco
* Colin O'Dell - https://github.com/colinodell
* Ronny Pfannschmidt - https://github.com/RonnyPfannschmidt
* Christian Fetzer - https://github.com/fetzerch
* Jonathan Stewmon - https://github.com/jstewmon
* Matthew Gamble - https://github.com/mwgamble
* Christian Clauss - https://github.com/cclauss
* Dawn James - https://github.com/dawngerpony
* Tsvika Shapira - https://github.com/tsvikas
* Marcos Boger - https://github.com/marcosboger
* Ofek Lev - https://github.com/ofek
* Art Pelling - https://github.com/artpelling
* Markéta Machová - https://github.com/MeggyCal

View File

@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2010 Meme Dough
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.