Skip to content

Replace StreamResource with DownloadHandler in Collaboration Kit docs #4444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: v24
Choose a base branch
from

Conversation

MatthewVaadin
Copy link
Contributor

DownloadHandler is now supported by Collaboration Kit (version 6.5.0). This updates the documentation to reflect that change.

NOTE: This should not be merged until platform:24.8.5 is released

Part of vaadin/collaboration-kit#94

@MatthewVaadin MatthewVaadin self-assigned this Jul 25, 2025
Copy link

AI Language Review

For the source code file AvatarGroupDocumentation:

  1. In the imageHandler() method, the change from StreamResource to DownloadHandler is appropriate for downloading or streaming images. However, the inner lambda function directly calls the new ByteArrayInputStream(imageBytes) without checking if imageBytes might be null or empty. You may want to add a null check or error handling to prevent potential issues if the user entity does not have an image.

For the AsciiDoc documentation file:

  1. Throughout the documentation, ensure that all code references to setImageProvider are updated to setImageHandler to maintain consistency with the updated Java code.
  2. Review the term "ensuranceClaims" for "insuranceClaims" in the example for a potential typo.

These are the primary areas that need attention based on the changes observed.

@MatthewVaadin MatthewVaadin marked this pull request as ready for review July 25, 2025 11:15
@MatthewVaadin MatthewVaadin requested a review from tamasmak July 25, 2025 11:23
@mstahv
Copy link
Member

mstahv commented Jul 29, 2025

Is there some specific reason to use this odd byte[] -> ByteArrayInputStream -> use helper to write input stream to outputstream pattern here (aka DownloadHandler.fromInputStream)? I don't have the changed Collaboration Kit API at my hands, but it would be more natural to me to push the images directly to the output stream 🤔

Related thinking in this test class (although in this case that would be even simpler): https://github.com/parttio/addon-demos/blob/main/src/main/java/org/example/otherexamples/NewDownloadAPI.java

@MatthewVaadin
Copy link
Contributor Author

@mstahv I was adapting the existing example to use the new DoenloadHandler using this as a reference. The intent was to show that this can be used for dynamic resources, so maybe we should use a dynamic example rather than implying that it should be used for static resources?

@mstahv
Copy link
Member

mstahv commented Jul 30, 2025

Yeah, I agree a dynamically generated example would be best and in that case it is even more clearer that you want to use the previous "Using DownloadEvent And Lambda Expression" approach that I was referring to 👍

@peholmst peholmst added the target/main cherry pick to main branch label Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/main cherry pick to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants