Skip to content

Commit 5a4fb5a

Browse files
authored
Merge pull request #9 from jowilf/dev
Add `thumbnail_size` property to ImageField
2 parents dd3a6d3 + a52e315 commit 5a4fb5a

File tree

15 files changed

+100
-100
lines changed

15 files changed

+100
-100
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## Version 0.1.2 - 2022-08-11
7+
## [0.1.3] - 2022-08-23
8+
9+
---
10+
11+
### Added
12+
- Add `thumbnail_size` property to ImageField by @jowilf https://github.com/jowilf/sqlalchemy-file/pull/9
13+
14+
## [0.1.2] - 2022-08-11
815

916
---
1017

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

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

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

124124
## Related projects and inspirations
125125

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

docs/changelog.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## Version 0.1.2 - 2022-08-11
7+
## [0.1.3] - 2022-08-23
8+
9+
---
10+
11+
### Added
12+
- Add `thumbnail_size` property to ImageField in [#9](https://github.com/jowilf/sqlalchemy-file/pull/9)
13+
14+
## [0.1.2] - 2022-08-11
815

916
---
1017

docs/index.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Overview
22

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

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

123123
## Related projects and inspirations
124124

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

docs/tutorial/using-files-in-models.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ You can use two Column type in your model.
2929

3030
Inherits all attributes and methods from [FileField][sqlalchemy_file.types.FileField], but also validates that the
3131
uploaded file is a valid image.
32-
!!! info
32+
!!! note
3333
Using [ImageField][sqlalchemy_file.types.ImageField] is like
3434
using [FileField][sqlalchemy_file.types.FileField]
35-
with [ImageValidator][sqlalchemy_file.validators.ImageValidator]
35+
with [ImageValidator][sqlalchemy_file.validators.ImageValidator] and
36+
[ThumbnailGenerator][sqlalchemy_file.processors.ThumbnailGenerator]
37+
3638

3739
!!! example
3840
```Python
3941
from sqlalchemy import Column, Integer, String
4042
from sqlalchemy.ext.declarative import declarative_base
41-
4243
from sqlalchemy_file import ImageField
4344

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

5051
id = Column(Integer, autoincrement=True, primary_key=True)
5152
title = Column(String(100), unique=True)
52-
cover = Column(ImageField)
53+
cover = Column(ImageField(thumbnail_size=(128, 128)))
5354
```
5455
## Uploaded Files Information
5556
Whenever a supported object is assigned to a [FileField][sqlalchemy_file.types.FileField] or [ImageField][sqlalchemy_file.types.ImageField]

docs_src/tutorial/using-files-in-models/002_imagefield_example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class Book(Base):
1010

1111
id = Column(Integer, autoincrement=True, primary_key=True)
1212
title = Column(String(100), unique=True)
13-
cover = Column(ImageField)
13+
cover = Column(ImageField(thumbnail_size=(128, 128)))

mkdocs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
site_name: SQLAlchemy File
2-
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.
2+
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.
33
site_url: https://jowilf.github.io/sqlalchemy-file
44
repo_name: jowilf/sqlalchemy-file
55
repo_url: https://github.com/jowilf/sqlalchemy-file
@@ -64,8 +64,8 @@ plugins:
6464
rendering:
6565
show_root_heading: true
6666
show_source: false
67-
watch:
68-
- sqlalchemy_file
67+
watch:
68+
- sqlalchemy_file
6969

7070

7171
extra:

poetry.lock

+40-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sqlalchemy-file"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "SQLAlchemy-file is a SQLAlchemy extension for attaching files to SQLAlchemy model and uploading them to various storage."
55
authors = ["Jocelin Hounon <[email protected]>"]
66
license = "MIT"
@@ -37,8 +37,7 @@ Pillow = "^9.2.0"
3737
fasteners = "^0.17.3"
3838
black = "^22.6.0"
3939
coverage = { extras = ["toml"], version = "^6.4.2" }
40-
flake8 = "^5.0.4"
41-
flake8-bugbear = "^22.7.1"
40+
flake8 = "^3.9.2"
4241
mypy = "^0.971"
4342
isort = "^5.10.1"
4443
mkdocs-material = "^8.2.7"

sqlalchemy_file/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.0"
1+
__version__ = "0.1.3"
22

33
from .file import File as File
44
from .types import FileField as FileField

sqlalchemy_file/helpers.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import Any, Dict, Union
88

99
INMEMORY_FILESIZE = 1024 * 1024
10+
LOCAL_STORAGE_DRIVER_NAME = "Local Storage"
1011

1112

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

0 commit comments

Comments
 (0)