Unzipping a tar.gz archive using Google Apps Script

Having trouble unzipping the file available at [https://wwwinfo.mfcr.cz/ares/ares_vreo_all.tar.gz][1] into my Google Drive folder.

I've successfully downloaded the file using a Google script, but I'm experiencing issues with the unzip process. Could someone kindly assist me with this?

Thank you in advance!

Update: Below is the code snippet:

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);
}

However, I encountered the following error:

Exception: Could not decompress gzip.

I suspect it's not decompressing as expected, so I'm seeking alternative solutions. If anyone has any insights, please do share! [1]:

Answer №1

If you want to decompress a file, the Utilities Class can help you with that task.

To decompress a gzip file, simply use the ungzip() method:

var dataBlob = Utilities.newBlob("Some text to compress using gzip compression");

// Create the compressed blob.
var gzipData = Utilities.gzip(dataBlob, "text.gz");

// Decompress the data.
var uncompressedData = Utilities.ungzip(gzipData);

This example is provided in the official guide found at documentation.

If you're interested, you can also check out the answer posted here which explains how to utilize the Utilities Class in combination with Google Drive.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bypassing a forward slash / when handling variables in an Ajax URL

I am currently dealing with pre-existing code that validates a user's submission by sending it to a specific URL using Ajax: var url = '/foo/bar/' + valuea + '/' + valueb + '/' + valuec; This information is then sent vi ...

The remove() function is failing when attempting to add input fields dynamically

Hello, I am currently facing an issue with dynamically generating input fields based on AJAX results. Unfortunately, the .remove() function is not working as expected and my current solution involves repetitive code. Any guidance or assistance would be g ...

Tips for updating the value of a nested object within an array using JavaScript

I'm currently working with React to update the state when a user triggers the delete button. The data structure involves nested objects inside another nested object within an array. const data = [ { id: 2, adminId: 2, roleId: 1, stor ...

The Dropdownlist jQuery is having trouble retrieving the database value

Within my database, there is a column labeled Sequence that contains integer values. For the edit function in my application, I need to display this selected number within a jQuery dropdown list. When making an AJAX call, I provide the ProductId parameter ...

Improving the method of extracting an ID from a form submission in Javascript and Django

My current code is functional, but I can't shake the feeling that it's a bit rough around the edges. Here's a simplified version of what I have: JQuery ready: <script type="text/javascript"> $(document).ready(function() { ...

Capture the attention of users through directives

I'm currently working on a script that checks for any mentioned users and then saves them to an array. This allows me to later apply methods to these users. For instance, assigning a role to a user. Capture the mentioned user(s) in the message (mess ...

How can the "dragenter" event be allowed to pass through child elements?

https://jsfiddle.net/7scfk81L/ The structure of my document is as follows: <div id="container"> <div id="inner"></div> </div> I have added listeners for dragEnter and dragLeave to the container element. However, when I drag in ...

Error: Uncaught [🍍]: The function "getActivePinia()" was invoked without an active Pinia instance present. Ensure that you have called "app.use(pinia)" before attempting to utilize a store

I encountered an issue while trying to access a store in Pinia for my Vue web application. Despite installing Pinia and setting app.use(createPinia()), I keep receiving the following error message: Uncaught Error: [ ...

Printing does not work when using Window.print()

I am facing an error message "Stack over flow at line:0" in Internet Explorer when using the code below to print my Aspx web page. However, in Firefox, nothing seems to happen. Can anyone help me identify the issue? <head> <script language="ja ...

Retrieve the folder and file name selected by the user in the browser

Can the client's directory path be obtained for a file uploaded to a server? ...

In ASP.NET, show a message when attempting to close the window without performing a PostBack

I have a specific requirement for displaying a message to the user only when they close my ASP.NET Web Forms page or navigate away from it, but not when interacting with certain elements like Buttons, LinkButtons, AutoPostBack elements, etc. Below is the ...

Utilizing Hyperlinks in jQuery DataTables Cell with Data Pulled from Mysql Table

I have a question that builds upon the one before it: How to display a hyperlink in a cell with jQuery DataTables There is also a Fiddle link provided My current query revolves around implementing hyperlinks when fetching data from a MySQL database table ...

I need help with a process to extract information from a database and convert it into an object specifically for my situation

Currently, I am utilizing the postgres row_to_json function to retrieve data that has been stored using JSON.stringify(). However, upon retrieval and attempting to parse it with JSON.parse(), an error message stating "unexpected token ," is returned. The ...

Issues have arisen due to server calls being affected by AngularJS routing

I have implemented AngularJS in a nodewebkit application. There are three main views: Home.html Conversation.html Login.html Upon login, the following code is executed: $state.go('home.main'); which triggers the following state c ...

Testing components in React Native using asynchronous Jest methods

I have a component that triggers a fetch request when it mounts and then displays the results. I've been struggling to create a test snapshot of this component after the request is completed. I've searched on various forums like SO but haven&apo ...

Adding items from the JSON data to a nested array at index i

In my project, I am working with two files: index.js and list.json. My goal is to extract an element from list.json and insert it into a nested array following the structure [hour][visits per hour]. The hour refers to the index of the hour; for example, ...

Is it possible to execute a SQLite query using ajax jQuery?

I am facing an issue with incorporating sqlite queries into the back getJSON response function in my phonegap application. After trying to implement this code, I continuously encounter the following error: INVALID_STATE_ERR: DOM Exception 11: An attemp ...

Tips for showcasing data in the autocomplete feature

I have implemented the following code to show values: function retrieveValues(input) { var xhttp; if (input.length == 0) { document.getElementById("output").innerHTML = ""; return; } xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = functi ...

Issues with implementing jQuery on Crispy Forms input fields are causing unexpected behavior

<div id="div_id_code" class="form-group"> <label for="id_code" class="control-label col-lg-2 requiredField"> Code<span class="asteriskField">*</span> </label> <div class="controls "> <input type="text" ...

Using different time intervals, setTimeout can be implemented within a for loop

I have an array consisting of different objects, each containing a time property with various values. My goal is to iterate through this array and use a setTimeout function inside to print out the name of each object after a specific amount of time based ...