Repository navigation
Implement GET/PUT/DELETE for /shells/asset-information/thumbnail - #618
Open
paul-gerber-svg wants to merge 4 commits into
Open
paul-gerber-svg wants to merge 4 commits into
paul-gerber-svg wants to merge 4 commits into
Conversation
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
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.
Member
|
This needs to be adapted when #627 is merged. |
Member
|
@paul-gerber-svg can you add the tests here? |
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.
s-heppner
requested changes
Oct 23, 2026
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() |
Member
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the server endpoint
/asset-information/thumbnailis notimplemented; all three methods (
GET,PUT,DELETE) are mapped toself.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,PUTandDELETEfor/shells/{aasIdentifier}/asset-information/thumbnailaccording tothe specification.
GETreturns the thumbnail file referenced byAssetInformation.default_thumbnail.PUTaccepts amultipart/form-dataupload (fileNameandfile), stores it viathe file store, and updates
default_thumbnailaccordingly, removingthe previous thumbnail file if the path changes.
DELETEremoves thestored 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