Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1841 sails upload error #1842

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions demo/src/main/webapp/js/ng-file-upload-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,9 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
data.file = config.file;
}
for (key in data) {
if(key === 'file') {
continue;
}
if (data.hasOwnProperty(key)) {
var val = data[key];
if (config.formDataAppender) {
Expand All @@ -745,6 +748,13 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
}
}
}
if(data.file) {
if (config.formDataAppender) {
config.formDataAppender(formData, 'file', data.file);
} else {
addFieldToFormData(formData, data.file, 'file');
}
}

return formData;
});
Expand Down Expand Up @@ -1041,8 +1051,8 @@ ngFileUpload.service('Upload', ['$parse', '$timeout', '$compile', '$q', 'UploadE
if (validateAfterResize) {
upload.validate(allNewFiles, keep ? prevValidFiles.length : 0, ngModel, attr, scope)
.then(function (validationResult) {
valids = validationResult.validsFiles;
invalids = validationResult.invalidsFiles;
valids = validationResult.validFiles;
invalids = validationResult.invalidFiles;
updateModel();
});
} else {
Expand Down Expand Up @@ -2096,14 +2106,15 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct

el.on('loadedmetadata', success);
el.on('error', error);

var count = 0;

function checkLoadError() {
count++;
$timeout(function () {
if (el[0].parentNode) {
if (el[0].duration) {
success();
} else if (count > 10) {
} else if (count++ > 10) {
error();
} else {
checkLoadError();
Expand Down
5 changes: 3 additions & 2 deletions demo/src/main/webapp/js/ng-file-upload-all.min.js

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions demo/src/main/webapp/js/ng-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
data.file = config.file;
}
for (key in data) {
if(key === 'file') {
continue;
}
if (data.hasOwnProperty(key)) {
var val = data[key];
if (config.formDataAppender) {
Expand All @@ -323,6 +326,13 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
}
}
}
if(data.file) {
if (config.formDataAppender) {
config.formDataAppender(formData, 'file', data.file);
} else {
addFieldToFormData(formData, data.file, 'file');
}
}

return formData;
});
Expand Down Expand Up @@ -619,8 +629,8 @@ ngFileUpload.service('Upload', ['$parse', '$timeout', '$compile', '$q', 'UploadE
if (validateAfterResize) {
upload.validate(allNewFiles, keep ? prevValidFiles.length : 0, ngModel, attr, scope)
.then(function (validationResult) {
valids = validationResult.validsFiles;
invalids = validationResult.invalidsFiles;
valids = validationResult.validFiles;
invalids = validationResult.invalidFiles;
updateModel();
});
} else {
Expand Down Expand Up @@ -1674,14 +1684,15 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct

el.on('loadedmetadata', success);
el.on('error', error);

var count = 0;

function checkLoadError() {
count++;
$timeout(function () {
if (el[0].parentNode) {
if (el[0].duration) {
success();
} else if (count > 10) {
} else if (count++ > 10) {
error();
} else {
checkLoadError();
Expand Down
4 changes: 2 additions & 2 deletions demo/src/main/webapp/js/ng-file-upload.min.js

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions dist/ng-file-upload-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,9 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
data.file = config.file;
}
for (key in data) {
if(key === 'file') {
continue;
}
if (data.hasOwnProperty(key)) {
var val = data[key];
if (config.formDataAppender) {
Expand All @@ -745,6 +748,13 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
}
}
}
if(data.file) {
if (config.formDataAppender) {
config.formDataAppender(formData, 'file', data.file);
} else {
addFieldToFormData(formData, data.file, 'file');
}
}

return formData;
});
Expand Down Expand Up @@ -1041,8 +1051,8 @@ ngFileUpload.service('Upload', ['$parse', '$timeout', '$compile', '$q', 'UploadE
if (validateAfterResize) {
upload.validate(allNewFiles, keep ? prevValidFiles.length : 0, ngModel, attr, scope)
.then(function (validationResult) {
valids = validationResult.validsFiles;
invalids = validationResult.invalidsFiles;
valids = validationResult.validFiles;
invalids = validationResult.invalidFiles;
updateModel();
});
} else {
Expand Down Expand Up @@ -2096,14 +2106,15 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct

el.on('loadedmetadata', success);
el.on('error', error);

var count = 0;

function checkLoadError() {
count++;
$timeout(function () {
if (el[0].parentNode) {
if (el[0].duration) {
success();
} else if (count > 10) {
} else if (count++ > 10) {
error();
} else {
checkLoadError();
Expand Down
5 changes: 3 additions & 2 deletions dist/ng-file-upload-all.min.js

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions dist/ng-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
data.file = config.file;
}
for (key in data) {
if(key === 'file') {
continue;
}
if (data.hasOwnProperty(key)) {
var val = data[key];
if (config.formDataAppender) {
Expand All @@ -323,6 +326,13 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
}
}
}
if(data.file) {
if (config.formDataAppender) {
config.formDataAppender(formData, 'file', data.file);
} else {
addFieldToFormData(formData, data.file, 'file');
}
}

return formData;
});
Expand Down Expand Up @@ -619,8 +629,8 @@ ngFileUpload.service('Upload', ['$parse', '$timeout', '$compile', '$q', 'UploadE
if (validateAfterResize) {
upload.validate(allNewFiles, keep ? prevValidFiles.length : 0, ngModel, attr, scope)
.then(function (validationResult) {
valids = validationResult.validsFiles;
invalids = validationResult.invalidsFiles;
valids = validationResult.validFiles;
invalids = validationResult.invalidFiles;
updateModel();
});
} else {
Expand Down Expand Up @@ -1674,14 +1684,15 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct

el.on('loadedmetadata', success);
el.on('error', error);

var count = 0;

function checkLoadError() {
count++;
$timeout(function () {
if (el[0].parentNode) {
if (el[0].duration) {
success();
} else if (count > 10) {
} else if (count++ > 10) {
error();
} else {
checkLoadError();
Expand Down
4 changes: 2 additions & 2 deletions dist/ng-file-upload.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
data.file = config.file;
}
for (key in data) {
if(key === 'file') {
continue;
}
if (data.hasOwnProperty(key)) {
var val = data[key];
if (config.formDataAppender) {
Expand All @@ -323,6 +326,13 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
}
}
}
if(data.file) {
if (config.formDataAppender) {
config.formDataAppender(formData, 'file', data.file);
} else {
addFieldToFormData(formData, data.file, 'file');
}
}

return formData;
});
Expand Down