Skip to content

Commit 2a78291

Browse files
committed
Added XHR on Upload Response
1 parent cd53417 commit 2a78291

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/main/java/gwt/material/design/addins/client/fileuploader/MaterialFileUploader.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
255255
});
256256

257257
uploader.on(FileUploaderEvents.ERROR, (object, response) -> {
258+
UploadResponse uploadResponse = new UploadResponse();
258259
int code = 200;
259260
String statusText = "";
260261

@@ -263,6 +264,7 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
263264
if (file.xhr != null) {
264265
code = file.xhr.status;
265266
statusText = file.xhr.statusText;
267+
uploadResponse.setXhr(file.xhr);
266268
}
267269

268270
String body = "";
@@ -289,8 +291,10 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
289291
globalResponse = response;
290292
}
291293

292-
293-
ErrorEvent.fire(this, convertUploadFile(file), new UploadResponse(code, statusText, body));
294+
uploadResponse.setCode(code);
295+
uploadResponse.setMessage(statusText);
296+
uploadResponse.setBody(body);
297+
ErrorEvent.fire(this, convertUploadFile(file), uploadResponse);
294298
});
295299

296300
uploader.on(FileUploaderEvents.TOTAL_UPLOAD_PROGRESS, (progress, totalBytes, totalBytesSent) -> {

src/main/java/gwt/material/design/addins/client/fileuploader/base/UploadResponse.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*/
2020
package gwt.material.design.addins.client.fileuploader.base;
2121

22+
import gwt.material.design.addins.client.fileuploader.js.XHR;
23+
2224
/**
2325
* Upload Response with Code (e.g 404, 503, 200) and message ("File Upload url not found etc."
2426
*
@@ -30,6 +32,10 @@ public class UploadResponse {
3032
private int code;
3133
private String message;
3234
private String body;
35+
private XHR xhr;
36+
37+
public UploadResponse() {
38+
}
3339

3440
public UploadResponse(int code, String message) {
3541
this.code = code;
@@ -80,4 +86,12 @@ public String getBody() {
8086
public void setBody(String body) {
8187
this.body = body;
8288
}
89+
90+
public XHR getXhr() {
91+
return xhr;
92+
}
93+
94+
public void setXhr(XHR xhr) {
95+
this.xhr = xhr;
96+
}
8397
}

0 commit comments

Comments
 (0)