Skip to content

The Django Rest Framework application is designed to enable users to update images and obtain distinct thumbnails based on their account tier.

Notifications You must be signed in to change notification settings

fortyfortyy/ImageUploaderApi

Repository files navigation

Image Uploader API

Live Project Link: https://dev-imageuploadapi.up.railway.app/api/v1/accounts/register/

This is based on the Django Rest Framework application that implements the all necessary logic to work with GSC (Google Cloud Storage), Redis, Celery and PostgreSQL. It does provide ONLY Django Rest Framework UI, so please follow the docs to see available URLS. I hope you not gonna spam my bucket :)

Table of contents

Technologies Used

  • Python 3.10
  • Django 4.1.7
  • Redis
  • Celery
  • Django REST 3.14
  • Google Cloud Storage 2.7.0
  • PostgreSQL 2.9.5
  • Docker-compose
  • Django-Alluth

Features Implemented

  • users can upload images via HTTP request
  • users can list their uploaded images
  • three builtin account tiers Basic, Premium and Enterprise
    • users that have a "Basic" plan after uploading an image get:
      • a link to a thumbnail that's 200px in height
    • users that have a "Premium" plan get:
      • a link to a thumbnail that's 200px in height
    • a link to a thumbnail that's 400px in height
      • a link to the originally uploaded image
    • users that have a "Enterprise" plan get
      • a link to a thumbnail that's 200px in height
      • a link to a thumbnail that's 400px in height
      • a link to the originally uploaded image
      • the ability to fetch a link to the (binary) image that expires after several seconds (user can specify any number between 300 and 30000) and download it
  • apart from the builtin tiers, admins can create arbitrary tiers with the following things configurable:
    • arbitrary thumbnail sizes
    • presence of the link to the originally uploaded file
    • ability to generate expiring links
  • admin UI has been done via django-admin
  • tests validation of the image and account tiers
  • performance considerations(implemented basic cache for 15 seconds, distributed task queue to be able to process a lot of images)

(back to top)

Available Urls

PUBLIC URLS

ADMIN URLS

AUTHENTICATED USERS

ADVANCED API DOCS

(back to top)

How To Set Up Locally

First of all, you need to:

  • Create a bucket in GCS link , with the name of your desire.
  • Create IAM Policy link , GENERATE A KEY and download *.json file with the credentials.
  • PUT YOUR CREDENTIALS TO THE SOURCE OF THIS PROJECT AND CHANGE THE NAME TO "private_credentials.json" (look at settings.py)

The easiest approach is to run docker-compose. It should work without any problems. The docker-compose approach is based on google cloud storage. If you have the desire to save locally the images and thumbnails please, visit this PR and see the changes.

  • clone the repo
  • go to the project folder
  • run docker-compose up -d --build
  • create a test super account with docker-compose exec backend python manage.py create_test_superuser
  • visit (try both URLs in case the error occurred) localhost:8000/admin/ or 127.0.0.1:8000/admin/ and paste the generated credentials

If you have any questions, let me know at [email protected]

(back to top)

About

The Django Rest Framework application is designed to enable users to update images and obtain distinct thumbnails based on their account tier.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published