feat: add warning log

This commit is contained in:
Methapon Metanipat 2024-09-02 13:17:52 +07:00
parent 132e1e9acd
commit 6dcbfea30a

View file

@ -44,7 +44,10 @@ export async function handler(key: string, event: string): Promise<boolean> {
try {
const stat = await minioClient.statObject(bucket, pathname);
cachedMetadata[key] = { size: stat.size, type: stat.metaData["content-type"] };
if (stat.size > 1024 * 1024 * 100) cachedBuffer[key] = Buffer.from([]);
if (stat.size > 1024 * 1024 * 100) {
console.warn("[AMQ] File is too large. Data extract will be skipped.");
cachedBuffer[key] = Buffer.from([]);
}
} catch (e: any) {
if (e.code === "NoSuchKey") {
console.info(`[AMQ] Key: ${key} received but cannot be found.`);