An API that allow registered users to upload an image in PNG or JPG format
- Prepare env:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
- Run migrations via:
python manage.py migrate
- Run server via:
python manage.py runserver
- Add superuser via:
python manage.py createsuperuser
- Login as admin:
http://127.0.0.1:8000/admin/
- Define tier at
http://127.0.0.1:8000/admin/image_api/accounttier/add/
- Create user at
http://127.0.0.1:8000/admin/auth/user/
- Add user profile at
http://127.0.0.1:8000/admin/image_api/userprofile/add/
, select created user and defined tier - Login as user at:
http://127.0.0.1:8000/dj-rest-auth/login/
. - Now you can upload images via
http://127.0.0.1:8000/user-images/
- You can view uploaded images.
- Run tests via
python manage.py test
- dynamic images are stored as .jpeg files (to save memory space)
- while uploading image validation logic checks for min_width and min_height (to avoid blurred effect)
- to generate dynamic image only height value is required, width is calculated according to image aspect ratio
- storage backed is defined as DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage" (need to be changed for production)