Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Jun 11, 2024
1 parent da39e6d commit 71bf305
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions examples/aws-nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,36 +200,31 @@ app.get('/s3/multipart/:uploadId', (req, res, next) => {
return
}

const parts = [];
const parts = []

function listPartsPage(startsAt = undefined) {
let config = {
client.send(new ListPartsCommand({
Bucket: process.env.COMPANION_AWS_BUCKET,
Key: key,
UploadId: uploadId,
};

if (startsAt) config.PartNumberMarker = startsAt;

client.send(new ListPartsCommand(config), (err, data) => {
PartNumberMarker: startsAt,
}), (err, data) => {
if (err) {
next(err);
return;
next(err)
return
}

parts.push(...data.Parts);
parts.push(...data.Parts)

// continue to get list of all uploaded parts until the IsTruncated flag is false
if (data.IsTruncated) {
listPartsPage(data.NextPartNumberMarker);
listPartsPage(data.NextPartNumberMarker)
} else {
res.json(parts);
res.json(parts)
}
});
})
}

listPartsPage();

listPartsPage()
})

function isValidPart (part) {
Expand Down

0 comments on commit 71bf305

Please sign in to comment.