Skip to content

Commit d835638

Browse files
committed
Merge pull request #443 from darrylkuhn/master
Handle "file is no longer valid" errors
2 parents 04976b6 + 79c9c49 commit d835638

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

angular-file-upload.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ module
467467
});
468468
});
469469

470+
if ( typeof(item._file.size) != 'number' ) {
471+
throw new TypeError('The file specified is no longer valid');
472+
}
473+
470474
form.append(item.alias, item._file, item.file.name);
471475

472476
xhr.upload.onprogress = function(event) {
@@ -812,7 +816,12 @@ module
812816
* Uploads a FileItem
813817
*/
814818
FileItem.prototype.upload = function() {
815-
this.uploader.uploadItem(this);
819+
try {
820+
this.uploader.uploadItem(this);
821+
} catch (e) {
822+
this.uploader._onCompleteItem( this, '', 0, [] );
823+
this.uploader._onErrorItem( this, '', 0, [] );
824+
}
816825
};
817826
/**
818827
* Cancels uploading of FileItem

0 commit comments

Comments
 (0)