-
Notifications
You must be signed in to change notification settings - Fork 210
feat: Add docs for DownloadHandler #4309
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
base: latest
Are you sure you want to change the base?
Conversation
AI Language Review
|
== Using Custom Servlet and Request Parameters | ||
|
||
You can create a custom servlet which handles "image" as a relative URL: | ||
|
||
[source,java] | ||
---- | ||
@WebServlet(urlPatterns = "/image", name = "DynamicContentServlet") | ||
public class DynamicContentServlet extends HttpServlet { | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) | ||
throws ServletException, IOException { | ||
resp.setContentType("image/svg+xml"); | ||
String name = req.getParameter("name"); | ||
if (name == null) { | ||
name = ""; | ||
} | ||
String svg = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" | ||
+ "<svg xmlns='http://www.w3.org/2000/svg' " | ||
+ "xmlns:xlink='http://www.w3.org/1999/xlink'>" | ||
+ "<rect x='10' y='10' height='100' width='100' " | ||
+ "style=' fill: #90C3D4'/><text x='30' y='30' fill='red'>" | ||
+ name + "</text>" + "</svg>"; | ||
resp.getWriter().write(svg); | ||
} | ||
} | ||
---- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from the old article, I'd keep it just in case if someone is interested in a low level servlet way of downloading a content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive documentation for the new DownloadHandler API in Vaadin 24.8, including multiple usage scenarios and API customization examples.
- Removed the legacy dynamic content documentation.
- Added detailed documentation for DownloadHandler covering classpath resource downloads, file system downloads, dynamic InputStream downloads, progress tracking, and custom download handlers.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
articles/flow/advanced/dynamic-content.adoc | Legacy documentation removed. |
articles/flow/advanced/downloads.adoc | New documentation added for the DownloadHandler API. |
Comments suppressed due to low confidence (1)
articles/flow/advanced/downloads.adoc:241
- [nitpick] The class name 'LinkWithM5Validation' is ambiguous; consider renaming it to something more descriptive, such as 'LinkWithChecksumValidation'.
private static class LinkWithM5Validation extends Anchor {
Co-authored-by: Copilot <[email protected]>
MessageDigest md5 = MessageDigest.getInstance("MD5"); | ||
byte[] digest = md5.digest(data); | ||
String base64Md5 = Base64.getEncoder().encodeToString(digest); | ||
event.getResponse().setHeader("Content-MD5", base64Md5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example with calculating MD5 checksum and checking it on the client isn't perhaps a realistic case. I'd think of a better case for when setting a header is useful in download handler, feel free to share a better example if you have any.
Adds a documentation for new API for handling downloads in Vaadin 24.8.
Fixes #4303