Skip to content

Commit

Permalink
feat(storage): add s3 storage backend config with SSE-C
Browse files Browse the repository at this point in the history
  • Loading branch information
fugal-dy committed Nov 29, 2023
1 parent 68c9f3c commit 41291e8
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 539 deletions.
2 changes: 1 addition & 1 deletion alexandria/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class Meta:
ordering = ["-created_at"]


@receiver(models.signals.pre_delete, sender=File)
@receiver(models.signals.post_delete, sender=File)
def auto_delete_file_on_delete(sender, instance, **kwargs):
"""Delete file from filesystem when `File` object is deleted."""

Expand Down
4 changes: 2 additions & 2 deletions alexandria/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from alexandria.core.models import File


def create_thumbnail(_file):
def create_thumbnail(_file: File):
with NamedTemporaryFile() as tmp:
temp_file = Path(tmp.name)
manager = PreviewManager(str(temp_file.parent))
Expand All @@ -33,7 +33,7 @@ def create_thumbnail(_file):

with path_to_preview_image.open("rb") as thumb:
thumb_file = File.objects.create(
name=f"{_file.name}.jpg",
name=f"{_file.name}_preview.jpg",
document=_file.document,
variant=File.Variant.THUMBNAIL,
original=_file,
Expand Down
24 changes: 0 additions & 24 deletions alexandria/settings/alexandria.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,6 @@ def default(default_dev=env.NOTSET, default_prod=env.NOTSET):
ALEXANDRIA_VALIDATION_CLASSES = env.list("ALEXANDRIA_VALIDATION_CLASSES", default=[])

# Storage
ALEXANDRIA_MEDIA_STORAGE_SERVICE = env.str(
"ALEXANDRIA_MEDIA_STORAGE_SERVICE", default="minio"
)
ALEXANDRIA_MINIO_STORAGE_ENDPOINT = env.str(
"ALEXANDRIA_MINIO_STORAGE_ENDPOINT", default="minio:9000"
)
ALEXANDRIA_MINIO_STORAGE_ACCESS_KEY = env.str(
"ALEXANDRIA_MINIO_STORAGE_ACCESS_KEY", default="minio"
)
ALEXANDRIA_MINIO_STORAGE_SECRET_KEY = env.str(
"ALEXANDRIA_MINIO_STORAGE_SECRET_KEY", default="minio123"
)
ALEXANDRIA_MINIO_STORAGE_USE_HTTPS = env.bool(
"ALEXANDRIA_MINIO_STORAGE_USE_HTTPS", default=False
)
ALEXANDRIA_MINIO_STORAGE_MEDIA_BUCKET_NAME = env.str(
"ALEXANDRIA_MINIO_STORAGE_MEDIA_BUCKET_NAME", default="alexandria-media"
)
ALEXANDRIA_MINIO_STORAGE_AUTO_CREATE_MEDIA_BUCKET = env.bool(
"ALEXANDRIA_MINIO_STORAGE_AUTO_CREATE_MEDIA_BUCKET", default=True
)
ALEXANDRIA_MINIO_PRESIGNED_TTL_MINUTES = env.str(
"ALEXANDRIA_MINIO_PRESIGNED_TTL_MINUTES", default=15
)
ALEXANDRIA_STORAGE_SSE_SECRET = env.str(
"ALEXANDRIA_STORAGE_SSE_SECRET", default="not-very-secret"
)
Expand Down
Loading

0 comments on commit 41291e8

Please sign in to comment.