mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Merge pull request #3 from dato/export_job_inject_aws_endpoint_setting
Subclass boto3.Session to use AWS_S3_ENDPOINT_URL
This commit is contained in:
commit
f96ddaa3e1
1 changed files with 10 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
import logging
|
||||
from uuid import uuid4
|
||||
|
||||
from boto3.session import Session as BotoSession
|
||||
from s3_tar import S3Tar
|
||||
from storages.backends.s3boto3 import S3Boto3Storage
|
||||
|
||||
|
@ -25,6 +26,14 @@ from bookwyrm.utils.tar import BookwyrmTarFile
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BookwyrmAwsSession(BotoSession):
|
||||
"""a boto session that always uses settings.AWS_S3_ENDPOINT_URL"""
|
||||
|
||||
def client(service_name, **kwargs):
|
||||
kwargs["endpoint_url"] = settings.AWS_S3_ENDPOINT_URL
|
||||
return super().client(service_name, **kwargs)
|
||||
|
||||
|
||||
class BookwyrmExportJob(ParentJob):
|
||||
"""entry for a specific request to export a bookwyrm user"""
|
||||
|
||||
|
@ -211,6 +220,7 @@ class AddFileToTar(ChildJob):
|
|||
s3_job = S3Tar(
|
||||
settings.AWS_STORAGE_BUCKET_NAME,
|
||||
f"exports/{filename}.tar.gz",
|
||||
session=BookwyrmAwsSession(),
|
||||
)
|
||||
|
||||
# save json file
|
||||
|
|
Loading…
Reference in a new issue