netomia commented on issue #485: URL: https://github.com/apache/cordova-plugin-camera/issues/485#issuecomment-2567054152
> Thanks @thevirajshelke , although VIDEO is my primary concern. > > For what it's worth (and for those who only need PHOTO support), I've had success using `<input id="fileInput" type="file" accept="image/*" multiple/>` for importing multiple photos just using FileReader and `cordova-plugin-file`: > > ``` > var fileInput = document.getElementByID('fileInput'); > > fileInput.onchange = function(e){ > > var f = e.target.files, x = 0, fileList = []; > > function importFile(i) { > console.log('Importing '+(1 + x)+' of '+f.length+' files'); > var R = new FileReader(); > R.name = f[I].name; // File name for writing to later > fileList.push(R.name); > R.onload = function () { > window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function (dataDir) { > dataDir.getFile(R.name, {create: true, exclusive: false}, function(fileEntry) { > fileEntry.createWriter(function (fileWriter) { > fileWriter.onwriteend = function() { > x++; > if (x < f.length){ > importFile(x) > } else { > // All images have been imported > console.log(fileList.join(',')) > } > }; > fileWriter.onerror = function (e) { > console.log("Failed file write: " + e.toString()); > }; > fileWriter.write(R.result); > }); > }, function (er) { > console.log(er) > }); > }, function (err) { > console.log(err) > }); > }; > R.readAsArrayBuffer(f[i]) > } > > importFile(x); > }; > ``` > > As long as I step through each file one at a time like this - I haven't run into any memory issues, even in older devices. This method does not allow you to lower the quality the imported photos like the Camera plugin does, but for those looking for a solution in the meantime, this might do the trick. > > This method does not play well with videos - especially large ones, so I would still love to see this plugin support multiple video import ;). Just wanted to give a heads up. This code contains 3 instances of wrong letter case. Threw me off for a while :-) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org