0

I am started to work with nodejs octokit. With following code (sample code from github documentation) I was able to retrieve a .tar file from a Github repository:

await octokit.request('GET /repos/{owner}/{repo}/tarball/{ref}', {
  owner: 'octocat',
  repo: 'hello-world',
  ref: 'ref'
})

The received .tar file ist stored in a json file, coded like:

data: w [ArrayBuffer] {
    [Uint8Contents]: <01 e7 ... 26850189 more bytes>,
    byteLength: 26850289
  }

I am searching for a solution to convert the ArrayBuffer with the [Uint8Contents] to an actual tar file and save it to a folder in my nodejs project. A lot of googling didn“t bring up a solution.

Happy for some help.

Harald
  • 243
  • 2
  • 12

1 Answers1

1

Found the solution. It is quite easy:

const fs = require('fs');
fs.writeFileSync('filename or complete path', Buffer.from(buffer_data));
Harald
  • 243
  • 2
  • 12