Adds ContentType to setFileValue#791
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the file upload functionality by adding a new contentType parameter to the setFileValue method so that file uploads can automatically include MIME type information. The changes span service interfaces, controller endpoints, client APIs, backend operations, and tests to update method signatures and documentation accordingly.
- Updated service and repository interfaces to include a contentType parameter.
- Modified controllers and client APIs to pass along the content type.
- Revised tests and documentation to verify the new behavior.
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| basyx.submodelservice-http/SubmodelServiceHTTPApiController.java | Updated controller to pass file.getContentType() to setFileValue. |
| basyx.submodelservice-feature-operation-dispatching/AbstractSubmodelServiceDecorator.java | Propagated contentType parameter in decorator method. |
| basyx.submodelservice-feature-mqtt/MqttSubmodelService.java | Updated method signature to include contentType. |
| basyx.submodelservice-feature-authorization/AuthorizedSubmodelService.java | Adjusted setFileValue to forward contentType after permission check. |
| basyx.submodelservice-core/SubmodelServiceSuite.java | Modified tests to pass a MIME type alongside file streams. |
| basyx.submodelservice/SubmodelService.java | Updated interface and Javadoc to include contentType. |
| basyx.submodelservice-client/SubmodelServiceApi.java & ConnectedSubmodelService.java | Updated client API to build multipart requests with a provided contentType. |
| basyx.submodelservice-backend/SubmodelFileOperations.java & CrudSubmodelService.java | Updated file persistence logic to use the new contentType when creating FileMetadata and FileBlobValue. |
| basyx.submodelrepository (and submodules) | Updated repository methods, API controllers, and tests to include contentType for file operations. |
| basyx.aasenvironment-core/DefaultAASEnvironment.java | Adjusted method for setting file content to pass a default contentType string. |
Comments suppressed due to low confidence (2)
basyx.submodelservice/basyx.submodelservice-client/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/client/internal/SubmodelServiceApi.java:1199
- Consider adding error handling to manage cases where ContentType.parse(contentType) might throw an exception on invalid MIME type strings.
ContentType fileContentType = contentType != null ? ContentType.parse(contentType) : ContentType.DEFAULT_BINARY;
basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceSuite.java:432
- Consider adding tests to cover edge cases for the contentType parameter, such as null or invalid MIME type values, to ensure robust handling.
submodelService.setFileValue(idShortPathPropertyInSmeCol, "jsonFile1.json", "application/json", getInputStreamOfDummyFile(DUMMY_JSON_1));

Description of Changes
This PR adds the
contentTypeparameter to thesetFileValuemethod, allowing it to automatically set the content type when using the attachment endpoint. The implementation follows the same pattern assetThumbnailin the AAS Service.