My file downloading function takes more than 6 minutes. Therefore, I couldn't download the whole files. Is there anyway to complete the download within 6 minutes? Or any other solution ? Html
<html>
<form id="downloadpdf">
<input id="urlclass" type="text" name="urlname" />
</form>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var urllink = []; //this value assigned by another function. But let us assign statics variable as example urllink={“url1,url2,url3”}
$(document).ready(function() {
$("#downloadpdf").submit(function() {
$("#urlclass").val(urllink);
google.script.run.withSuccessHandler(function(retsearch){
}).downloadthefile(this);
});
});
</script>
</html>
code.gs
function downloadthefile(urlpass) {
var timezone = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
var now = Utilities.formatDate(new Date(),timezone, "EEE MMM d yyyy HH:mm:ss");
var dest_folder = DriveApp.createFolder(now);
var dest_folder_id = DriveApp.getFoldersByName(dest_folder).next().getId();
var source_folder = DriveApp.getFolderById(“the source folder id");
var dest_folder = DriveApp.getFolderById(dest_folder_id );
// The url that is passed to the function as string
var urlstring = urlpass.urlname;
// Make array of url
var resultarray = urlstring.split(',');
for(var i=0; i < resultarray.length; i++){
var fileurl = resultarray[i];
// Retrieve the url Id
var fileid = fileurl.match(/[-\w]{25,}/);
var file = DriveApp.getFileById(fileid);
var filecopy = file.makeCopy(file.getName());
dest_folder.addFile(filecopy);
}
}