fix: error file too large
This commit is contained in:
parent
798fd4b37b
commit
d1bdf89fd6
1 changed files with 20 additions and 2 deletions
|
|
@ -136,7 +136,15 @@ async function handleNotFoundRecord(
|
|||
) {
|
||||
const path = stripLeadingSlash(pathname.split("/").slice(0, -1).join("/") + "/");
|
||||
const filename = pathname.split("/").at(-1);
|
||||
const base64 = errorKey.includes(key) ? "" : Buffer.from(buffer).toString("base64");
|
||||
let base64 = "";
|
||||
|
||||
if (!errorKey.includes(key)) {
|
||||
try {
|
||||
Buffer.from(buffer).toString("base64");
|
||||
} catch (e) {
|
||||
console.warn("[WARN] Cannot extract data from the file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
const metadata = {
|
||||
pathname,
|
||||
|
|
@ -191,12 +199,22 @@ async function handleFoundRecord(
|
|||
metadata.fileType = stat.type;
|
||||
metadata.upload = true;
|
||||
|
||||
let base64 = "";
|
||||
|
||||
if (!errorKey.includes(key)) {
|
||||
try {
|
||||
Buffer.from(buffer).toString("base64");
|
||||
} catch (e) {
|
||||
console.warn("[WARN] Cannot extract data from the file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
const result = await esClient
|
||||
.index({
|
||||
pipeline: "attachment",
|
||||
index: DEFAULT_INDEX!,
|
||||
document: {
|
||||
data: errorKey.includes(key) ? "" : Buffer.from(buffer).toString("base64"),
|
||||
data: base64,
|
||||
...metadata,
|
||||
},
|
||||
refresh: "wait_for",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue