Use a stream when uploading database contents

This commit is contained in:
Robert 2023-01-06 15:00:24 +00:00
parent ff3337ee1b
commit 6ce923c375
3 changed files with 7 additions and 7 deletions

View file

@ -48,17 +48,18 @@ async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
// Although we are uploading arbitrary file contents to the API, it's worth
// noting that it's the API's job to validate that the contents is acceptable.
// This API method is available to anyone with write access to the repo.
const payload = fs.readFileSync(await (0, util_1.bundleDb)(config, language, codeql, language));
const bundledDb = await (0, util_1.bundleDb)(config, language, codeql, language);
try {
await client.request(`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, {
owner: repositoryNwo.owner,
repo: repositoryNwo.repo,
language,
name: `${language}-database`,
data: payload,
data: fs.createReadStream(bundledDb),
headers: {
authorization: `token ${apiDetails.auth}`,
"Content-Type": "application/zip",
"Content-Length": fs.statSync(bundledDb).size,
},
});
logger.debug(`Successfully uploaded database for ${language}`);