I am trying to unzip the file: [https://wwwinfo.mfcr.cz/ares/ares_vreo_all.tar.gz][1] into google drive folder.
So, I have downloaded the file using google script, but can not properly unzip it. Could you, please, help me with it?
Thank you in advance!
Update: Here is my code
function updateDB() {
var url = 'https://wwwinfo.mfcr.cz/ares/ares_vreo_all.tar.gz';
var blob = UrlFetchApp.fetch(url).getBlob();
var folder = DriveApp.getFolderById('fileid');
var archive = folder.createFile(blob);
unzip(archive);
}
function unzip(archive){
var zipblob = archive.getBlob();
var uncompressed1 = Utilities.ungzip(zipblob);
}
So I receive the following error:
Exception: Could not decompress gzip.
I guess it does not decompress normally, that is why I am asking if you would know different way [1]: https://wwwinfo.mfcr.cz/ares/ares_vreo_all.tar.gz
CodePudding user response:
You can use the Utilities
Class to unzip your File.
To unzip the gzip you have to call the ungzip()
method:
var textBlob = Utilities.newBlob("Some text to compress using gzip compression");
// Create the compressed blob.
var gzipBlob = Utilities.gzip(textBlob, "text.gz");
// Uncompress the data.
var uncompressedBlob = Utilities.ungzip(gzipBlob);
That's the example provided in the official documentation.
You can also take a look at the answer given to this question that also explains how to use the Utilities
Class in combination with Google Drive.