u
This commit is contained in:
@@ -152,7 +152,7 @@ export async function insertAttachments(pool, tx, sql, manifestId, files) {
|
|||||||
|
|
||||||
// Generate thumbnail server-side (e.g. pdftocairo + sharp for PDF)
|
// Generate thumbnail server-side (e.g. pdftocairo + sharp for PDF)
|
||||||
const { thumbavif, thumbx, thumby } = await generateDocumentThumb(a.content, a.mimetype, { filename: a.name });
|
const { thumbavif, thumbx, thumby } = await generateDocumentThumb(a.content, a.mimetype, { filename: a.name });
|
||||||
|
|
||||||
const fileRes = await request(pool, tx)
|
const fileRes = await request(pool, tx)
|
||||||
.input('hash', a.hash)
|
.input('hash', a.hash)
|
||||||
.input('mimetype', a.mimetype)
|
.input('mimetype', a.mimetype)
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ const THUMB_MAX = 200;
|
|||||||
* @returns {Promise<Buffer>}
|
* @returns {Promise<Buffer>}
|
||||||
*/
|
*/
|
||||||
async function renderPdfPageToPng(pdfBuffer) {
|
async function renderPdfPageToPng(pdfBuffer) {
|
||||||
const images = await pdfToPng(pdfBuffer, { dpi: 150, singleFile: true });
|
// The WASM converter may transfer (and detach) its input ArrayBuffer. Give it
|
||||||
|
// an isolated copy so the upload buffer remains usable by SQL and logging.
|
||||||
|
const pdfBytes = new Uint8Array(pdfBuffer);
|
||||||
|
const images = await pdfToPng(pdfBytes, { dpi: 150, singleFile: true });
|
||||||
if (!images || images.length === 0 || !images[0].data) {
|
if (!images || images.length === 0 || !images[0].data) {
|
||||||
throw new Error('pdfconvert-wasm produced no image output');
|
throw new Error('pdfconvert-wasm produced no image output');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user