yakovmeister / pdf2image

A utility for converting pdf to image and base64 format.
MIT License
435 stars 141 forks source link

Store Converted pages to S3 Bucket #201

Closed HafizAmeerHamza closed 9 months ago

HafizAmeerHamza commented 9 months ago

I am using this package in my project to convert pdf files to images, everything working fine, I store the converted files into local directory but now the scope changes and I am looking if this package allows or have support to directly store files into S3 bucket?

mskec commented 9 months ago

I don't believe we will add this support. You can easily do it yourself by converting pages to buffer.

Something like this

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

const s3 = new S3Client({ region: 'eu-west-1' });

const bufferResponse = await convert(pageToConvertAsImage, { responseType: "buffer" });
const uploadParams = {
  Bucket: 'BUCKET_NAME',
  Key: 'FILE_NAME',
  Body: bufferResponse.buffer,
};
await s3.send(new PutObjectCommand(uploadParams));
HafizAmeerHamza commented 9 months ago

okay, Thanks for your suggestion. Very helpful. :)