8000 fix: Remove faulty method (#21459) · vaadin/flow@8504858 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 8504858

Browse files
authored
fix: Remove faulty method (#21459)
* fix: Remove faulty method remove sendUploadResponse as ResponseHandled is used and should be the one to override for custom responses. * Add info on filename and contentType for fileXHR to UploadMetadata * Change explanation to multipart has
1 parent 1b279e5 commit 8504858

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

flow-server/src/main/java/com/vaadin/flow/server/streams/UploadEvent.java

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -116,32 +116,6 @@ public InputStream getInputStream() {
116116
}
117117
}
118118

119-
/**
120-
* Write response for handled upload.
121-
*
122-
* @param success
123-
* {@code true} will send 200 http ok, {@code false} will send
124-
* 500 error code
125-
*/
126-
public void sendUploadResponse(boolean success) {
127-
response.setContentType(
128-
ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8);
129-
if (success) {
130-
try (PrintWriter writer = response.getWriter()) {
131-
try {
132-
writer.print("<html><body>upload handled</body></html>");
133-
} finally {
134-
writer.flush();
135-
}
136-
} catch (IOException e) {
137-
LoggerFactory.getLogger(UploadEvent.class)
138-
.error("Error writing upload response", e);
139-
}
140-
} else {
141-
response.setStatus(HttpStatusCode.INTERNAL_SERVER_ERROR.getCode());
142-
}
143-
}
144-
145119
/**
146120
* Get {@link VaadinRequest} for download event.
147121
*
@@ -170,7 +144,9 @@ public VaadinSession getSession() {
170144
}
171145

172146
/**
173-
* Get the set file name.
147+
* Get the set file name for current upload.
148+
* <p>
149+
* The file name will only be available for multipart uploads.
174150
*
175151
* @return file name
176152
*/
@@ -180,6 +156,8 @@ public String getFileName() {
180156

181157
/**
182158
* Get the content type for the data to download.
159+
* <p>
160+
* The content type will only be available for multipart uploads.
183161
*
184162
* @return set content type
185163
*/

flow-server/src/main/java/com/vaadin/flow/server/streams/UploadHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ public interface UploadHandler extends ElementRequestHandler {
5959
* stored for this specific handler registration.
6060
* <p>
6161
* After upload of all files is done the method
62-
* {@link UploadEvent#sendUploadResponse(boolean)} can be called to write an
63-
* upload response. The method
64-
* {@link #responseHandled(boolean, VaadinResponse)} will be called when all
65-
* upload items have been handled.
62+
* {@link #responseHandled(boolean, VaadinResponse)} will be called.
6663
*
6764
* @param event
6865
* upload event containing the necessary data for getting the

flow-server/src/main/java/com/vaadin/flow/server/streams/UploadMetadata.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
/**
2020
* Metadata for successful upload.
21+
* <p>
22+
* The fileName and contentType will only be available for multipart uploads.
2123
*/
2224
public record UploadMetadata(String fileName, String contentType,
2325
long contentLength) {

0 commit comments

Comments
 (0)
0