fllabcks hmmm
This commit is contained in:
@@ -77,9 +77,23 @@ export default function add(pool) {
|
||||
if (rawContent == null) {
|
||||
throw new Error('Content required');
|
||||
}
|
||||
const content = Buffer.isBuffer(rawContent)
|
||||
? rawContent
|
||||
: Buffer.from(rawContent);
|
||||
let content;
|
||||
if (Buffer.isBuffer(rawContent)) {
|
||||
content = rawContent;
|
||||
} else if (typeof rawContent === 'string') {
|
||||
const trimmed = rawContent.trim();
|
||||
if (mimetype === 'application/pdf' || trimmed.startsWith('JVBER') || /^[A-Za-z0-9+/=]+$/.test(trimmed.slice(0, 100))) {
|
||||
try {
|
||||
content = Buffer.from(trimmed, 'base64');
|
||||
} catch {
|
||||
content = Buffer.from(rawContent, 'utf8');
|
||||
}
|
||||
} else {
|
||||
content = Buffer.from(rawContent, 'utf8');
|
||||
}
|
||||
} else {
|
||||
content = Buffer.from(rawContent);
|
||||
}
|
||||
|
||||
if (rawSort !== undefined && rawSort !== null) {
|
||||
if (!Number.isFinite(rawSort)) {
|
||||
@@ -143,7 +157,7 @@ export default function add(pool) {
|
||||
}
|
||||
|
||||
if (!thumbavif) {
|
||||
const generated = await generateDocumentThumb(content, mimetype);
|
||||
const generated = await generateDocumentThumb(content, mimetype, { filename: rawName });
|
||||
thumbavif = generated.thumbavif;
|
||||
thumbx = generated.thumbx;
|
||||
thumby = generated.thumby;
|
||||
|
||||
Reference in New Issue
Block a user