Creating big files with GAS

1,633 views
Skip to first unread message

Tatiane Fernandes

unread,
Jul 7, 2021, 7:59:52 AM7/7/21
to Google Apps Script Community
Hello there!

I am trying to compress a folder via GAS and return a url where I can download this compressed folder. It's works well with small folders, but I get this error: 

Exception: File mybigfolder.zip exceeds the maximum file size.

when I try to use it with bigger folders (like, 1GB of data).


I think the error is in DriveApp.createFile method, but the drive API doesn't says anything about a size limit when creating a file just using blob (there is a limit if I create senting content and name parameters, but this is not the case).

Any idea of how I can deal with it?

Thanks a lot!

Tatiane

Marcos Gomes

unread,
Jul 7, 2021, 8:38:57 AM7/7/21
to google-apps-sc...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/773c9260-b49f-4600-b48a-b72eadf5d4aen%40googlegroups.com.

dimud...@gmail.com

unread,
Jul 7, 2021, 8:49:46 AM7/7/21
to Google Apps Script Community
You have a few constraints to consider. 

There are size limits with the Drive API depending on the type of upload you perform when creating a file. 

For file sizes larger that 5MB you'd typically leverage resumable uploads(https://developers.google.com/drive/api/v3/manage-uploads#resumable). 

Unfortunately, neither the built-in service (DriveApp) nor the advanced service (Drive) supports that feature. Your only option to do this from Apps Script is to call the Drive API directly using UrlFetchApp.fetch(). 

The constraint with Apps Script is its 6 minute execution quota, but you might be able to work around that by uploading your data in chunks. You might even be able to get around the 6 minute execution limit by leveraging a GCP service like Cloud Pubsub or Cloud Tasks to offload chunk uploads to separate threads of execution (where each chunk has its own 6 minute window of execution). Easier said than done though.




Tatiane Fernandes

unread,
Jul 7, 2021, 11:25:50 AM7/7/21
to Google Apps Script Community

Thanks guys, 

I'll take a look at Tanaka solution and try to adapt it to what I need (or try a server-side solution).

Tati


Reply all
Reply to author
Forward
0 new messages