Skip to content

Commit

Permalink
fix download issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zehfernandes committed Dec 30, 2023
1 parent 900b0df commit d08b110
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ async function getDeploymentId(domain) {
}

async function downloadFile(deploymentId, fileId, destination) {
let path = `/v6/deployments/${deploymentId}/files/${fileId}`;
let path = `/v7/deployments/${deploymentId}/files/${fileId}`;
if (VERCEL_TEAM) path += `?teamId=${VERCEL_TEAM}`;
const response = await getFromAPI(path);
return new Promise((resolve, reject) => {
fs.writeFile(destination, response.body, function (err) {
// Assuming response.body contains the base64 encoded data
const encodedValue = JSON.parse(response.body).data;
const decodedValue = Buffer.from(encodedValue, 'base64'); // Decode base64 to binary buffer

fs.writeFile(destination, decodedValue, function (err) {
if (err) reject(err);
resolve();
});
Expand All @@ -92,6 +96,7 @@ function getFromAPI(path) {
headers: {
Authorization: `Bearer ${VERCEL_TOKEN}`,
},
responseType: 'buffer',
retry: {
limit: 0,
},
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d08b110

Please sign in to comment.