I have Error event Run JavaScript alert("Error is: " + errorThrown); on uploadService component.
And I'm getting Error is: Bad Request
Followed every step in the tutorial... please help!
I have Error event Run JavaScript alert("Error is: " + errorThrown); on uploadService component.
And I'm getting Error is: Bad Request
Followed every step in the tutorial... please help!
Hello John,
Could you please give us a link to the tutorial, also please detail when do you get this in console (after what actions)?
http://devcenter.appery.io/tutorials/...
this tutorial.
I pass all steps, everything works, but the last step - testing file upload fails.
I log in successfully, then select 1 or more files and press upload button.
It returns a popup saying Error is: Bad Request
Hi John,
Unfortunatly that's a bug. We working on it.
But here is a quick workauround for you:
1 Create JS asset:.
2 Populate it with following code:
pre
function uploadMultipleFilesHelperNew(datasource, fileList) {
var isCorrectService = false;
if (datasource) {
if (datasource.service && datasource.service.requestOptions) {
var options = datasource.service.requestOptions;
isCorrectService = options.type === 'post' && options.contentType === false && /^.*\/files$/i.test(options.url);
}
}
if (isCorrectService) {
if (fileList) {
var data = new FormData();
for (var i = 0; i < fileList.length; i++) {
appendItem(data, fileList);
}
try {
datasource.execute({
'allowDataModification': false,
'processData': false,
'body': {data: data},
'cache': false
});
} catch (exception) {
console.log(exception.name + ' ' + exception.message);
hideSpinner();
}
}
} else {
console.warn('This data source not be supported in the method of upload multiple files');
}
Code: Select all
function appendItem(formData, item) {
if (item) {
if (item.type === 'file') {
item = item.files;
}
if (item instanceof FileList) {
for (var i = 0; i < item.length; i++) {
appendItem(formData, item[i]);
}
return;
}
var name;
if (item.name) {
name = item.name;
}
formData.append(name, item);
}
}
}
/pre
Ok, now you can use "uploadMultipleFilesHelperNew" instead of "uploadMultipleFilesHelper".
so you can invoke upload with following code:
pre
uploadMultipleFilesHelperNew(uploadService, Apperyio('file_input'));
/pre
Regards.
Thank you! could you please tell me where exactly should I place this file (and should I name in uploadMultipleFilesHelperNew ?) thanks!
Hello!
You would need to Create New--JS asset, you can give it any name.
Hi John,
i have added and tested ...it works ,
create new -- javescript
enter name : any name
open upload page -- design builder select upload button.
edit the JS script to :
uploadMultipleFilesHelperNew(uploadService, Apperyio('file_input'));
save it and test
I test ok on builder TEST, But run on mobile Device with export apk, the file selected button doesn't work out after click
Hi Yang,
Please user WEINRE debugger may be there some errors: http://devcenter.appery.io/documentat...
Also please try to use "virtual click" event instead of "click".
Regards.