Page 1 of 2

Multiple upload files new function

Posted: Wed Jul 15, 2015 10:41 pm
by Al7638578

Does this script still work? I found it in an old thread?

I'm assuming the data source would be something like:

LoginDB__files_upload_service // a service which uploads files to the files collection

and the file list would be at least 1 file such as:

image_base64_1 // A picture from the camera

or an array of file names taken with the camera?

I have saved 6 pictures from my camera into local storage and would like to upload all 6 to the files database. They are stored in Local Storage:

image_base64_1
image_base64_2
image_base64_3
image_base64_4
image_base64_5
image_base64_6

// Here's the function I'm talking about

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');
}
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);
}
return;
}
var name;
if (item.name) {
name = item.name;
}
formData.append(name, item);
}
}
}


Multiple upload files new function

Posted: Fri Jul 17, 2015 11:23 am
by Alena Prykhodko

Hello Al,

Please follow this tutorial https://devcenter.appery.io/tutorials...


Multiple upload files new function

Posted: Fri Jul 17, 2015 2:07 pm
by Al7638578

I'm getting the error: file_input is not defined


Multiple upload files new function

Posted: Fri Jul 17, 2015 2:24 pm
by Al7638578

Now I'm getting a success but the files are not there.


Multiple upload files new function

Posted: Fri Jul 17, 2015 2:56 pm
by Al7638578

OK .... finally got it working. Uploads 3 files from my computer which I can select all at one time. I guess what I need to do is call this function for every file I need to upload and pass it the file names. I have stored the images from the camers as:

uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_0'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_1'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_2'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_3'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_4'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_5'));

Is there a way to pass all file names at the same time instead of calling the upload function 1 time for every file?


Multiple upload files new function

Posted: Fri Jul 17, 2015 5:37 pm
by Al7638578

I am stuck again, this will not upload photos from the camera as I have mentioned above. It will upload photos from my computer but that is not what I am trying to do. I need this to upload photos taken from the camera.


Multiple upload files new function

Posted: Fri Jul 17, 2015 5:57 pm
by Illya Stepanov

Hello Al -

In this case please check this tutorial: https://devcenter.appery.io/documenta...


Multiple upload files new function

Posted: Fri Jul 17, 2015 6:17 pm
by Al7638578

Over and over again lol. I have been to that tutorial and I have tried this both ways. I am trying to upload 6 pictures from the camera. What is the proper way to do this? Is it a combination of both tutorials? I just keep running around in circles going through your documentation.

Can this be done?
Am I wasting my time?
I have been working on this for 2 weeks. If I am missing something can you let me know what it is lol.


Multiple upload files new function

Posted: Sat Jul 18, 2015 4:23 pm
by Al7638578

This isn't solved, who marked it as solved?


Multiple upload files new function

Posted: Sat Jul 18, 2015 11:48 pm
by Evgene Karachevtsev

Hello Al,

We used to have this tutorial, please check the app made with it, hope it will be helpful for you. Also please don't forget to link it with your db :
https://www.dropbox.com/s/mwhtf5z3zjh...