Skip to content

Commit

Permalink
Merge pull request #9 from jowilf/dev
Browse files Browse the repository at this point in the history
Add `thumbnail_size` property to ImageField
  • Loading branch information
jowilf authored Aug 23, 2022
2 parents dd3a6d3 + a52e315 commit 5a4fb5a
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 100 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version 0.1.2 - 2022-08-11
## [0.1.3] - 2022-08-23

---

### Added
- Add `thumbnail_size` property to ImageField by @jowilf https://github.com/jowilf/sqlalchemy-file/pull/9

## [0.1.2] - 2022-08-11

---

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


**SQLAlchemy-file** is a [SQLAlchemy](https://www.sqlalchemy.org/) extension for attaching files to SQLAlchemy model and
uploading them to various storage such as Amazon S3, Rackspace CloudFiles, Google Storage and others
uploading them to various storage such as Local Storage, Amazon S3, Rackspace CloudFiles, Google Storage and others
using [Apache Libcloud](https://github.com/apache/libcloud).

<p align="center">
Expand Down Expand Up @@ -123,7 +123,9 @@ with Session(engine) as session:

## Related projects and inspirations

* [Depot: ](https://github.com/amol-/depot) When I was looking for a library like this, depot was the
best I saw. But it offers less storage backend, doesn't support multiple files and doesn't work with
[SQLModel](https://github.com/tiangolo/sqlmodel). This project inspired **SQLAlchemy-file** extensively
* [filedepot: ](https://github.com/amol-/depot) When I was looking for a library like this, depot was the
best I saw. This project inspired **SQLAlchemy-file** extensively
and some features are implemented the same.
* [sqlalchemy-media](https://github.com/pylover/sqlalchemy-media) Another attachment extension for SqlAlchemy
to manage assets which are associated with database models

9 changes: 8 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version 0.1.2 - 2022-08-11
## [0.1.3] - 2022-08-23

---

### Added
- Add `thumbnail_size` property to ImageField in [#9](https://github.com/jowilf/sqlalchemy-file/pull/9)

## [0.1.2] - 2022-08-11

---

Expand Down
9 changes: 5 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Overview

**SQLAlchemy-file** is a [SQLAlchemy](https://www.sqlalchemy.org/) extension for attaching files to SQLAlchemy model and
uploading them to various storage such as Amazon S3, Rackspace CloudFiles, Google Storage and others
uploading them to various storage such as Local Storage, Amazon S3, Rackspace CloudFiles, Google Storage and others
using [Apache Libcloud](https://github.com/apache/libcloud).

<p align="center">
Expand Down Expand Up @@ -122,7 +122,8 @@ with Session(engine) as session:

## Related projects and inspirations

* [Depot: ](https://github.com/amol-/depot) When I was looking for a library like this, depot was the
best I saw. But it offers less storage backend, doesn't support multiple files and doesn't work with
[SQLModel](https://github.com/tiangolo/sqlmodel). This project inspired **SQLAlchemy-file** extensively
* [filedepot: ](https://github.com/amol-/depot) When I was looking for a library like this, depot was the
best I saw. This project inspired **SQLAlchemy-file** extensively
and some features are implemented the same.
* [sqlalchemy-media](https://github.com/pylover/sqlalchemy-media) Another attachment extension for SqlAlchemy
to manage assets which are associated with database models
9 changes: 5 additions & 4 deletions docs/tutorial/using-files-in-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ You can use two Column type in your model.

Inherits all attributes and methods from [FileField][sqlalchemy_file.types.FileField], but also validates that the
uploaded file is a valid image.
!!! info
!!! note
Using [ImageField][sqlalchemy_file.types.ImageField] is like
using [FileField][sqlalchemy_file.types.FileField]
with [ImageValidator][sqlalchemy_file.validators.ImageValidator]
with [ImageValidator][sqlalchemy_file.validators.ImageValidator] and
[ThumbnailGenerator][sqlalchemy_file.processors.ThumbnailGenerator]


!!! example
```Python
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

from sqlalchemy_file import ImageField

Base = declarative_base()
Expand All @@ -49,7 +50,7 @@ uploaded file is a valid image.

id = Column(Integer, autoincrement=True, primary_key=True)
title = Column(String(100), unique=True)
cover = Column(ImageField)
cover = Column(ImageField(thumbnail_size=(128, 128)))
```
## Uploaded Files Information
Whenever a supported object is assigned to a [FileField][sqlalchemy_file.types.FileField] or [ImageField][sqlalchemy_file.types.ImageField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ class Book(Base):

id = Column(Integer, autoincrement=True, primary_key=True)
title = Column(String(100), unique=True)
cover = Column(ImageField)
cover = Column(ImageField(thumbnail_size=(128, 128)))
6 changes: 3 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
site_name: SQLAlchemy File
site_description: SQLAlchemy-file is a SQLAlchemy extension for attaching files to SQLAlchemy model and uploading them to various storage such as Amazon S3, Rackspace CloudFiles, Google Storage and others using Apache Libcloud.
site_description: SQLAlchemy-file is a SQLAlchemy extension for attaching files to SQLAlchemy model and uploading them to various storage such as Local Storage Amazon S3, Rackspace CloudFiles, Google Storage and others using Apache Libcloud.
site_url: https://jowilf.github.io/sqlalchemy-file
repo_name: jowilf/sqlalchemy-file
repo_url: https://github.com/jowilf/sqlalchemy-file
Expand Down Expand Up @@ -64,8 +64,8 @@ plugins:
rendering:
show_root_heading: true
show_source: false
watch:
- sqlalchemy_file
watch:
- sqlalchemy_file


extra:
Expand Down
106 changes: 40 additions & 66 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sqlalchemy-file"
version = "0.1.2"
version = "0.1.3"
description = "SQLAlchemy-file is a SQLAlchemy extension for attaching files to SQLAlchemy model and uploading them to various storage."
authors = ["Jocelin Hounon <hounonj@gmail.com>"]
license = "MIT"
Expand Down Expand Up @@ -37,8 +37,7 @@ Pillow = "^9.2.0"
fasteners = "^0.17.3"
black = "^22.6.0"
coverage = { extras = ["toml"], version = "^6.4.2" }
flake8 = "^5.0.4"
flake8-bugbear = "^22.7.1"
flake8 = "^3.9.2"
mypy = "^0.971"
isort = "^5.10.1"
mkdocs-material = "^8.2.7"
Expand Down
2 changes: 1 addition & 1 deletion sqlalchemy_file/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.0"
__version__ = "0.1.3"

from .file import File as File
from .types import FileField as FileField
Expand Down
1 change: 1 addition & 0 deletions sqlalchemy_file/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any, Dict, Union

INMEMORY_FILESIZE = 1024 * 1024
LOCAL_STORAGE_DRIVER_NAME = "Local Storage"


def get_metadata_file_obj(metadata: Dict[str, Any]) -> "SpooledTemporaryFile[bytes]":
Expand Down
Loading

0 comments on commit 5a4fb5a

Please sign in to comment.