2
votes

I am trying to create a big file in Google Drive using Google Apps Script. This file merges three files. My code is:

    function unirFicheros(idDirectorio,nombreFichero, numeroFicheros){
      var nombreTotal=nombreFichero;
      var strTotal="";
      var docTotal = DocsList.createFile(nombreTotal, strTotal);
      Utilities.sleep(5000);
      Logger.log("SE CREA TOTAL: " + numeroFicheros);
      for(var i=1;i<=numeroFicheros;i++){
           Logger.log("ENTRO EN EL FOR");
           var nombrePartes=nombreFichero+i+".csv";
           Logger.log("NOMBREPARTES: " + nombrePartes);
           var id=listFilesInFolder(idDirectorio,nombrePartes);
           var docPartes = DocsList.getFileById(id);
           Utilities.sleep(5000);
           Logger.log("Existe el fichero");
           var str = docPartes.getContentAsString();
           Logger.log("UNE LA CADENA");
           strTotal = strTotal+str;
           Utilities.sleep(5000);
           docTotal.replace(strTotal);
           Utilities.sleep(30000);
        }
        return docTotal;
    }

The error occurs is:

Ejecución fallida: El archivo backup_actuaciones_PROD supera el tamaño de archivo máximo permitido. (Execution failed: File backup_actuaciones_PROD file size exceeds the maximum allowed.)

I trying to generate my file without format because internet says that these files are bigger. Actually, my file have 44 MB, but i need 427 MB.

Regards.

1

1 Answers

0
votes

DriveApp.createFile() includes a note that it... Throws an exception if content is larger than 10MB. I expect that this limitation also affects DocsList.createFile() and DocsList.replace().

You might have better results by avoiding the need to handle the entire contents of docTotal. Use File.append() to add the content of each file:

       ...
       var str = docPartes.getContentAsString();
       Logger.log("UNE LA CADENA");
       docTotal.append(str);
       ...