Skip to content

server: Implement the AAS thumbnail endpoints - #618

Open
paul-gerber-svg wants to merge 5 commits into
eclipse-basyx:developfrom
rwth-iat:fix/missing-endpoint-493
Open

paul-gerber-svg wants to merge 5 commits into
eclipse-basyx:developfrom
rwth-iat:fix/missing-endpoint-493

Conversation

@paul-gerber-svg

Copy link
Copy Markdown
Contributor

Currently, the server endpoint /asset-information/thumbnail is not
implemented; all three methods (GET, PUT, DELETE) are mapped to
self.not_implemented.

According to the AAS Repository Service OpenAPI Specification, the
endpoint should return, replace or delete the thumbnail file of a
selected AAS.

This change implements GET, PUT and DELETE for
/shells/{aasIdentifier}/asset-information/thumbnail according to
the specification. GET returns the thumbnail file referenced by
AssetInformation.default_thumbnail. PUT accepts a
multipart/form-data upload (fileName and file), stores it via
the file store, and updates default_thumbnail accordingly, removing
the previous thumbnail file if the path changes. DELETE removes the
stored file and clears default_thumbnail. All three reject external
(non-local) thumbnail references, since the server cannot serve or
manage files it does not store itself.

Fixes #493

hpoeche added a commit to rwth-iat/basyx-python-sdk that referenced this pull request Sep 1, 2026
…ation thumbnail endpoint."

This reverts commit 496190f, which held the content of eclipse-basyx#618. This was added for testing purpose only. Merge `develop` into this branch, after the PR was closed to obtain the same result.
@s-heppner s-heppner added this to the Release 2.3.0 milestone Sep 15, 2026
@s-heppner

Copy link
Copy Markdown
Member

This needs to be adapted when #627 is merged.

@s-heppner

Copy link
Copy Markdown
Member

@paul-gerber-svg can you add the tests here?

Comment on lines +615 to +640
def put_aas_thumbnail(
self, request: Request, url_args: Dict, response_t: Type[APIResponse], **_kwargs
) -> Response:
shell = self._get_shell(url_args)
filename = request.form.get("fileName")
if filename is None:
raise BadRequest("No 'fileName' specified!")
elif not filename.startswith("/"):
raise BadRequest(f"Given 'fileName' doesn't start with a slash (/): {filename}")

file_storage: Optional[FileStorage] = request.files.get("file")
if file_storage is None:
raise BadRequest("Missing file to upload")

old_thumbnail = shell.asset_information.default_thumbnail
new_path = self.file_store.add_file(filename, file_storage.stream, file_storage.mimetype)
if old_thumbnail is not None and old_thumbnail.path and old_thumbnail.path.startswith("/") \
and old_thumbnail.path != new_path:
try:
self.file_store.delete_file(old_thumbnail.path)
except KeyError:
pass

shell.asset_information.default_thumbnail = model.Resource(new_path, file_storage.mimetype)
self.object_store.commit(shell)
return response_t()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should check, for empty strings in mimetype == ''.
If the mimetype is an empty string, the resulting contentType also becomes an empty stirng, when it should be None.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: an empty mimetype is now stored as None. In fact, the empty string didn't even get stored.
ContentType rejects it, so the request failed with 500, after the previous thumbnail file had already been deleted.
PUT now validates its input first and deletes the old file only once the shell points to the new one.
test_shell_thumbnail_put_without_content_type_stores_none covers this.

paul-gerber-svg and others added 5 commits November 19, 2026 14:31
Currently, server endpoint `/asset-information/thumbnail`,
methods=["GET", "PUT", "DELETE"], endpoint=self.not_implemented is
not implemented.

According to the AAS Repository Service OpenAPI Specification, the
endpoint should return, replace or delete the thumbnail file of a
selected AAS.

This issue specifies eclipse-basyx#439.

This change implements `GET`, `PUT` and `DELETE` for
`/shells/{aasIdentifier}/asset-information/thumbnail` according to
the specification. `GET` returns the thumbnail file referenced by
`AssetInformation.default_thumbnail`. `PUT` accepts a
`multipart/form-data` upload (`fileName` and `file`), stores it via
the file store, and updates `default_thumbnail` accordingly, removing
the previous thumbnail file if the path changes. `DELETE` removes the
stored file and clears `default_thumbnail`. All three reject external
(non-local) thumbnail references, since the server cannot serve or
manage files it does not store itself.

Fixes eclipse-basyx#493
Previously, the "Currently Unimplemented" section of the server README
listed the `/shells/{aasIdentifier}/asset-information/thumbnail` route.
This change implements that route, so the entry is removed.

The section is also changed from a numbered list to bullet points.
This way, adding or removing an entry no longer means renumbering all
the entries after it.
@paul-gerber-svg
paul-gerber-svg force-pushed the fix/missing-endpoint-493 branch from bb1f945 to a46f92c Compare November 19, 2026 14:41
@paul-gerber-svg paul-gerber-svg changed the title Implement GET/PUT/DELETE for /shells/asset-information/thumbnail server: Implement the AAS thumbnail endpoints Nov 19, 2026
@paul-gerber-svg

Copy link
Copy Markdown
Contributor Author

Rebased onto develop, which includes #627, and added tests for all three thumbnail routes in test_shells.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server/app/interfaces/repository.py: Implement missing /shells/asset-information/thumbnail endpoint

2 participants