add file check to upload

This commit is contained in:
Iuri Matias 2016-10-12 20:01:21 -04:00
parent fe926382ce
commit 2b56ec6790
2 changed files with 8 additions and 0 deletions

View File

@ -146,6 +146,10 @@ var EmbarkJS =
var self = this; var self = this;
var file = inputSelector[0].files[0]; var file = inputSelector[0].files[0];
if (file === undefined) {
throw new Error('no file found');
}
var promise = new Promise(function(resolve, reject) { var promise = new Promise(function(resolve, reject) {
var reader = new FileReader(); var reader = new FileReader();
reader.onloadend = function() { reader.onloadend = function() {

View File

@ -99,6 +99,10 @@ EmbarkJS.Storage.uploadFile = function(inputSelector) {
var self = this; var self = this;
var file = inputSelector[0].files[0]; var file = inputSelector[0].files[0];
if (file === undefined) {
throw new Error('no file found');
}
var promise = new Promise(function(resolve, reject) { var promise = new Promise(function(resolve, reject) {
var reader = new FileReader(); var reader = new FileReader();
reader.onloadend = function() { reader.onloadend = function() {