From 7e4d8d6128e6ec08e266a01998f808b4e21cd0e1 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 16 May 2024 15:28:40 +0100 Subject: wip: replacing os.path.basename with Path --- pyblackbird_cc/resources/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pyblackbird_cc/resources/views.py') 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: -- cgit v1.2.3