Skip to content

Commit

Permalink
feat: continuate ZIP download
Browse files Browse the repository at this point in the history
  • Loading branch information
aleortega committed May 7, 2024
1 parent f09eee0 commit 6af8d98
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions consumer-server/bin/generate-zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ async function isActiveScene(fileName: string): Promise<boolean> {
async function downloadLODDirectoryAndCompressIt(
s3Client: S3Client,
bucket: string,
directory: string
directory: string,
continuationToken: string | undefined
) {
const params: ListObjectsV2Request = {
Bucket: bucket,
ContinuationToken: undefined,
ContinuationToken: continuationToken,
Prefix: "LOD/" + directory + "/",
}

Expand All @@ -67,6 +68,7 @@ async function downloadLODDirectoryAndCompressIt(
do {
const command = new ListObjectsV2Command(params)
fetched = await s3Client.send(command)
console.log({ fetched })
if (fetched.Contents) {
objectCount += fetched.Contents.length

Expand Down Expand Up @@ -163,6 +165,7 @@ async function zipFiles(directory: string, downloadDirectory: string) {
async function main() {
// grabs first argument passed from script
const directory = process.argv[2]
const continuationToken = process.argv[3]

const config = await createDotEnvConfigComponent({
path: [".env.default", ".env", ".env.admin"],
Expand All @@ -174,6 +177,8 @@ async function main() {
config.requireString("S3_BUCKET"),
])

console.log({ user, secret, bucket })

const s3Client = new S3Client({
region: REGION,
credentials: {
Expand All @@ -182,7 +187,7 @@ async function main() {
},
})

await downloadLODDirectoryAndCompressIt(s3Client, bucket, directory)
await downloadLODDirectoryAndCompressIt(s3Client, bucket, directory, continuationToken)
}

main().catch(console.error)

0 comments on commit 6af8d98

Please sign in to comment.