Skip to content

Commit

Permalink
feat: Zip files before uploading to s3 (#32)
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
bobbyg603 authored Nov 19, 2021
1 parent 24bed05 commit 23231d0
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 16 deletions.
12 changes: 8 additions & 4 deletions bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /usr/bin/env node
import { ApiClient, BugSplatApiClient, OAuthClientCredentialsClient, SymbolsApiClient } from '@bugsplat/js-api-client';
import AdmZip from 'adm-zip';
import commandLineArgs, { CommandLineOptions } from 'command-line-args';
import commandLineUsage from 'command-line-usage';
import fs from 'fs';
import { readFile, stat } from 'fs/promises';
import glob from 'glob-promise';
import { basename } from 'path';
Expand Down Expand Up @@ -102,9 +102,13 @@ import { argDefinitions, CommandLineDefinition, usageDefinitions } from './comma

const files = await Promise.all(
paths.map(async (path) => {
const size = (await stat(path)).size;
const name = basename(path);
const file = fs.createReadStream(path);
const zip = new AdmZip();
zip.addLocalFile(path);

const timestamp = new Date().getTime() / 1000;
const name = `${basename(path)}-${timestamp}.zip`;
const file = zip.toBuffer();
const size = file.length;
return {
name,
size,
Expand Down
67 changes: 56 additions & 11 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
},
"homepage": "https://github.com/BugSplat-Git/symbol-upload#readme",
"devDependencies": {
"@bugsplat/js-api-client": "^1.1.1",
"@types/adm-zip": "^0.4.34",
"@types/command-line-args": "^5.2.0",
"@types/command-line-usage": "^5.0.2",
"@types/glob": "^7.1.3",
Expand All @@ -43,7 +45,7 @@
"typescript": "^4.3.2"
},
"dependencies": {
"@bugsplat/js-api-client": "^1.1.0",
"adm-zip": "^0.5.9",
"command-line-args": "^5.2.0",
"command-line-usage": "^6.1.1",
"form-data": "^4.0.0",
Expand Down

0 comments on commit 23231d0

Please sign in to comment.