How to retrieve a ZIP file through a link and UNZIP it

8 views
Skip to first unread message

Wei Ying

unread,
May 21, 2019, 2:44:40 PM5/21/19
to Google Ads Scripts Forum
Hi, everyone.

I am working on a solution using AdWords script.
Based on the requirement, we need to retrieve a ZIP file through a link,
then use a JSON file included in that ZIP file.

I am not sure how this can be done on AdWords script.
I searched some resources and noticed that there is ZIP and UNZIP function supported in AdWords script.
But it doesn't work out well when I using UrlFetchApp to retrieve the ZIP file then using UNZIP to get included file.

#The code I tried to use
var zipUrl = 'https://XXXXXXXX';
var zipFile = UrlFetchApp.fetch(zipUrl);
var files = Utilities.unzip(zipFile);
while (files.hasNext()) {
    var file = files.next();
    Logger.log(file.getName());
}

If any one can give a guideline or sample code on this will be super helpful.
Thank you in advance!

Google Ads Scripts Forum Advisor Prod

unread,
May 21, 2019, 4:36:53 PM5/21/19
to adwords-scripts+apn2wqfh0lvz1qgo...@googlegroups.com, adwords...@googlegroups.com
Hello,

Please see this sample snippet that covers zipping and unzipping a file.

Regards,
Matt
Google Ads Scripts Team

ref:_00D1U1174p._5001UAqG4q:ref
Reply all
Reply to author
Forward
0 new messages