diff --git a/object_storage_api/schemas/image.py b/object_storage_api/schemas/image.py index 2650821..7b5c4ca 100644 --- a/object_storage_api/schemas/image.py +++ b/object_storage_api/schemas/image.py @@ -38,5 +38,5 @@ class ImageMetadataSchema(CreatedModifiedSchemaMixin, ImagePostMetadataSchema): class ImageSchema(ImageMetadataSchema): """Schema model for an image get request response.""" - inline_url: HttpUrl = Field(description="Presigned get URL to view the image file") + view_url: HttpUrl = Field(description="Presigned get URL to view the image file") download_url: HttpUrl = Field(description="Presigned get URL to download the image file") diff --git a/object_storage_api/services/image.py b/object_storage_api/services/image.py index 647b71d..da95074 100644 --- a/object_storage_api/services/image.py +++ b/object_storage_api/services/image.py @@ -82,14 +82,14 @@ def create(self, image_metadata: ImagePostMetadataSchema, upload_file: UploadFil def get(self, image_id: str) -> ImageSchema: """ - Retrieve an image's metadata with its presigned get download and inline urls by its ID. + Retrieve an image's metadata with its presigned get download and view urls by its ID. :param image_id: ID of the image to retrieve. :return: An image's metadata with its presigned get urls. """ image = self._image_repository.get(image_id=image_id) - (inline_url, download_url) = self._image_store.create_presigned_get(image) - return ImageSchema(**image.model_dump(), inline_url=inline_url, download_url=download_url) + (view_url, download_url) = self._image_store.create_presigned_get(image) + return ImageSchema(**image.model_dump(), view_url=view_url, download_url=download_url) def list(self, entity_id: Optional[str] = None, primary: Optional[bool] = None) -> list[ImageMetadataSchema]: """ diff --git a/object_storage_api/stores/image.py b/object_storage_api/stores/image.py index 4a316c2..9821844 100644 --- a/object_storage_api/stores/image.py +++ b/object_storage_api/stores/image.py @@ -58,7 +58,7 @@ def create_presigned_get(self, image: ImageOut) -> tuple[str, str]: "ExpiresIn": object_storage_config.presigned_url_expiry_seconds, } - inline_response = s3_client.generate_presigned_url(**parameters) + view_response = s3_client.generate_presigned_url(**parameters) attachment_response = s3_client.generate_presigned_url( **{ @@ -70,7 +70,7 @@ def create_presigned_get(self, image: ImageOut) -> tuple[str, str]: } ) - return (inline_response, attachment_response) + return (view_response, attachment_response) def delete(self, object_key: str) -> None: """ diff --git a/test/mock_data.py b/test/mock_data.py index a7e4313..67030df 100644 --- a/test/mock_data.py +++ b/test/mock_data.py @@ -170,6 +170,6 @@ IMAGE_GET_DATA_ALL_VALUES = { **IMAGE_GET_METADATA_DATA_ALL_VALUES, - "inline_url": ANY, + "view_url": ANY, "download_url": ANY, } diff --git a/test/unit/services/test_image.py b/test/unit/services/test_image.py index a0017d0..b0d5abd 100644 --- a/test/unit/services/test_image.py +++ b/test/unit/services/test_image.py @@ -191,7 +191,7 @@ def mock_get(self) -> None: ) self._expected_image = ImageSchema( **self._expected_image_out.model_dump(), - inline_url="https://fakepresignedurl.co.uk/inline", + view_url="https://fakepresignedurl.co.uk/inline", download_url="https://fakepresignedurl.co.uk/attachment", ) diff --git a/test/unit/stores/test_image.py b/test/unit/stores/test_image.py index 22a9476..cab1b82 100644 --- a/test/unit/stores/test_image.py +++ b/test/unit/stores/test_image.py @@ -118,8 +118,8 @@ class CreatePresignedURLDSL(ImageStoreDSL): """Base class for `create` tests.""" _image_out: ImageOut - _expected_presigned_inline_url: str - _obtained_presigned_inline_url: str + _expected_presigned_view_url: str + _obtained_presigned_view_url: str _expected_presigned_download_url: str _obtained_presigned_download_url: str @@ -133,10 +133,10 @@ def mock_create_presigned_get(self, image_in_data: dict) -> None: self._image_out = ImageOut(**ImageIn(**image_in_data).model_dump()) # Mock presigned url generation - self._expected_presigned_inline_url = "example_presigned_inline_url" + self._expected_presigned_view_url = "example_presigned_view_url" self._expected_presigned_download_url = "example_presigned_downloadurl" self.mock_s3_client.generate_presigned_url.side_effect = [ - self._expected_presigned_inline_url, + self._expected_presigned_view_url, self._expected_presigned_download_url, ] @@ -146,7 +146,7 @@ def call_create_presigned_get(self) -> None: `mock_create_presigned_get`. """ - (self._obtained_presigned_inline_url, self._obtained_presigned_download_url) = ( + (self._obtained_presigned_view_url, self._obtained_presigned_download_url) = ( self.image_store.create_presigned_get(self._image_out) ) @@ -177,7 +177,7 @@ def check_create_presigned_get_success(self) -> None: ] self.mock_s3_client.assert_has_calls(expected_calls) - assert self._obtained_presigned_inline_url == self._expected_presigned_inline_url + assert self._obtained_presigned_view_url == self._expected_presigned_view_url assert self._obtained_presigned_download_url == self._expected_presigned_download_url