我正在尝试压缩数千个小文件(10Kb或更少)。我通过搜索获取文件。问题是该过程需要很长时间才能达到Google App Script的极限。
有没有更有效的压缩方式?
function compressMonth() {
var month = '07';
var year = '2017';
var idOriginFolder = 'ABCDEfesn4342322';
var originFolder = DriveApp.getFolderById(idOriginFolder);
var nameCompressedFile = originFolder.getName()+year+' '+month+'.zip';
var searchString = '"'+idCarpetaOrigen+'" in parents and modifiedDate >= "'+year+'-'+month+'-01T00:00:00-03:00" and modifiedDate <= "'+year+'-'+month+'-'+'28T23:59:59-03:00"';
var foundFiles = DriveApp.searchFiles(searchString);
var blobIndex = [];
var fileBlob = null;
while (foundFiles.hasNext()){
fileBlob = foundFiles.next().getBlob();
blobIndex.push(fileBlob);
}
var compressedFolder = Utilities.zip(blobIndex,nameCompressedFile);
originFolder.createFile(compressedFolder);
}