mirror of
https://github.com/catdevnull/preciazo.git
synced 2025-02-23 10:06:24 +00:00
fix dataset fetch for index.md generation
This commit is contained in:
parent
3047d9f596
commit
74735260bb
1 changed files with 18 additions and 8 deletions
|
@ -36,18 +36,28 @@ function getS3Client() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listDirectory(directoryName: string) {
|
export async function listDirectory(directoryName: string) {
|
||||||
const { B2_BUCKET_NAME } = getVariables();
|
const { B2_BUCKET_NAME } = getVariables();
|
||||||
const s3 = getS3Client();
|
const s3 = getS3Client();
|
||||||
|
let allContents: string[] = [];
|
||||||
|
let continuationToken: string | undefined;
|
||||||
|
|
||||||
|
do {
|
||||||
const command = new ListObjectsV2Command({
|
const command = new ListObjectsV2Command({
|
||||||
Bucket: B2_BUCKET_NAME,
|
Bucket: B2_BUCKET_NAME,
|
||||||
Prefix: directoryName ? `${directoryName}/` : "",
|
Prefix: directoryName ? `${directoryName}/` : "",
|
||||||
Delimiter: "/",
|
Delimiter: "/",
|
||||||
|
ContinuationToken: continuationToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await s3.send(command);
|
const response = await s3.send(command);
|
||||||
return response.Contents?.map((item) => item.Key ?? "") ?? [];
|
allContents = allContents.concat(
|
||||||
|
response.Contents?.map((item) => item.Key ?? "") ?? []
|
||||||
|
);
|
||||||
|
continuationToken = response.NextContinuationToken;
|
||||||
|
} while (continuationToken);
|
||||||
|
|
||||||
|
return allContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getFileContent(fileName: string) {
|
export async function getFileContent(fileName: string) {
|
||||||
|
|
Loading…
Reference in a new issue