diff options
author | Matthew Lemon <y@yulqen.org> | 2024-05-16 15:28:40 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-05-16 15:28:40 +0100 |
commit | 7e4d8d6128e6ec08e266a01998f808b4e21cd0e1 (patch) | |
tree | 43f966e85d1456d10041d84e0db4ca6ba352ccf3 /pyblackbird_cc/resources/views.py | |
parent | 3c5fe347d9a75d5e636ae80e0e26c072aedc8a4f (diff) |
wip: replacing os.path.basename with Path
Diffstat (limited to 'pyblackbird_cc/resources/views.py')
-rw-r--r-- | pyblackbird_cc/resources/views.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index 91f2728..bc55842 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -6,6 +6,7 @@ from dataclasses import dataclass import boto3 from botocore.exceptions import ClientError +from botocore.utils import Path from django.conf import settings from django.contrib.auth.decorators import login_required from django.db import transaction @@ -43,7 +44,8 @@ class ResourceInfo: def _extract_metadata_from_resource(resource_obj) -> ResourceInfo | None: """ - This function extracts the resource information from the model object and returns it as a ResourceInfo object + This function extracts the resource information from the model object and returns it as a + ResourceInfo object :param resource_obj: :return: """ @@ -159,7 +161,7 @@ def upload_to_s3(pdf_files, thumbnail_files, snappedshotted_pages) -> bool: client.upload_file( img, settings.AWS_STORAGE_BUCKET_NAME, - f"snapshotted_pages/{os.path.basename(img)}", + f"snapshotted_pages/{Path(img).name}", ) else: for lst in snappedshotted_pages: @@ -168,7 +170,7 @@ def upload_to_s3(pdf_files, thumbnail_files, snappedshotted_pages) -> bool: client.upload_file( img, settings.AWS_STORAGE_BUCKET_NAME, - f"snapshotted_pages/{os.path.basename(img)}", + f"snapshotted_pages/{Path(img).name}", ) return True except ClientError: |