Skip to content

Commit

Permalink
fix: bytearray to buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
qilip committed Nov 15, 2023
1 parent 0b4fec0 commit 160e182
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const createThumbnail = async (byteArray) => {
const pdfThumbnail = async (byteArray) => {
const tempFileName = randomBytes(16).toString('hex');

const buffer = Buffer.from(byteArray);

const options = {
density: 72,
saveFilename: tempFileName,
Expand All @@ -67,7 +69,7 @@ const pdfThumbnail = async (byteArray) => {
height: 1440,
};

const storeAsImage = fromBuffer(byteArray, options);
const storeAsImage = fromBuffer(buffer, options);
const pageToConvertAsImage = 1;

const convertedImageBuffer = await storeAsImage(pageToConvertAsImage, {
Expand All @@ -92,6 +94,8 @@ export const handler = async (event) => {

if (!fileTypeResult) continue;

console.log('File type: ', fileTypeResult.mime);

if (fileTypeResult.mime.split('/')[0] === 'image') {
const thumbnail = await createThumbnail(byteArray);
await saveS3(key, thumbnail);
Expand Down

0 comments on commit 160e182

Please sign in to comment.