Skip to content

Commit 2fb7c1c

Browse files
committed
return error when status is not 2xx
1 parent d50012c commit 2fb7c1c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

file-uploader-progress.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
height: 4px;
7676
left: 0;
7777
position: absolute;
78-
width: 100%;
78+
width: 100%;
7979
--paper-progress-active-color: var(--file-uploader-progress-color, #2196f3);
8080
}
8181
</style>
@@ -168,6 +168,7 @@
168168
} else {
169169
this._currentFile = this._getFileInProgress();
170170
}
171+
this._opened = this.opened;
171172
},
172173

173174
_progressChanged() {

file-uploader.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@
174174
})
175175
.catch(err => {
176176
this.filesProgress.set(file, null);
177+
this.files.splice(this.files.indexOf(file), 1);
178+
this._updateProgress();
177179
this._setFailure(err && err.toString() ||
178180
`Error uploading ${file.name}`);
179-
this.fire('upload-failed', {file});
181+
this.fire('upload-failed', {file, error: this.failure});
180182
throw err;
181183
});
182184
});
@@ -233,7 +235,13 @@
233235
}
234236

235237
const xhr = new XMLHttpRequest();
236-
xhr.addEventListener('load', e => resolve({file, url}));
238+
xhr.addEventListener('loadend', e => {
239+
if (xhr.status >= 200 && xhr.status < 300) {
240+
resolve({file, url});
241+
} else {
242+
reject(xhr.statusText);
243+
}
244+
});
237245
xhr.addEventListener('error', e => reject(e.currentTarget.response));
238246
xhr.open(method, url, true);
239247

0 commit comments

Comments
 (0)