feat: do not process file more than 100MB
This commit is contained in:
parent
d1bdf89fd6
commit
95a6ad7770
1 changed files with 6 additions and 5 deletions
|
|
@ -40,6 +40,12 @@ export async function handler(key: string, event: string): Promise<boolean> {
|
|||
return await ensureDelete(pathname);
|
||||
}
|
||||
|
||||
if (!cachedMetadata[key]) {
|
||||
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 (!cachedBuffer[key]) {
|
||||
try {
|
||||
const stream = await minioClient.getObject(bucket, pathname);
|
||||
|
|
@ -56,11 +62,6 @@ export async function handler(key: string, event: string): Promise<boolean> {
|
|||
}
|
||||
}
|
||||
|
||||
if (!cachedMetadata[key]) {
|
||||
const stat = await minioClient.statObject(bucket, pathname);
|
||||
cachedMetadata[key] = { size: stat.size, type: stat.metaData["content-type"] };
|
||||
}
|
||||
|
||||
const rec = await popInfo(pathname);
|
||||
|
||||
if (rec) cachedRecord[key] = rec;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue