sqlalchemy-media

http://img.shields.io/pypi/v/sqlalchemy-media.svg Requirements Status https://travis-ci.org/pylover/sqlalchemy-media.svg?branch=master https://coveralls.io/repos/github/pylover/sqlalchemy-media/badge.svg?branch=master https://img.shields.io/badge/license-MIT-brightgreen.svg https://img.shields.io/github/stars/pylover/sqlalchemy-media.svg?style=social&label=Star

Why ?

Nowadays, most of the database applications are used to allow users to upload and attach files of various types to ORM models.

Handling those jobs is not simple if you have to care about Security, High-Availability, Scalability, CDN and more things you may have already been concerned. Accepting a file from public space, analysing, validating, processing(Normalizing) and making it available to public space again is the main goal of this project.

Sql-Alchemy is the best platform for implementing this stuff. It has the SqlAlchemy Mutable types facility to manipulate the objects with any type in-place. why not ?

Note

The main idea comes from dahlia’s SQLAlchemy-ImageAttach.

Overview

  • Storing and locating any file, tracking it by sqlalchemy models.
  • Storage layer is completely separated from data model, with a simple api: (put, delete, open, locate)
  • Using any SqlAlchemy data type which interfaces Python dictionary. This is achieved by using the SqlAlchemy Type Decorators and SqlAlchemy Mutable.
  • Offering delete_orphan flag to automatically delete files which orphaned via attribute set or delete from collections, or objects leaved in memory alone! by setting it’s last pointer to None.
  • Attaching files from Url, LocalFileSystem and Streams.
  • Extracting the file’s mimetype from the backend stream if possible, using magic module.
  • Limiting file size(min, max), to prevent DOS attacks.
  • Adding timestamp in url to help caching.
  • Auto generating thumbnails, using width, height and or ratio.
  • Analyzing files & images using magic and PIL.
  • Validating mimetype, width, height and image ratio.
  • Automatically resize & reformat images before store.

Indices and tables