I need to first download the image from a public url, convert the downloaded image file to a multer file so that I can call an existing api which then uploads the multer file. I've tried axios responseType: "blob"
and responseType: "arraybuffer"
but I'm having trouble converting both responses into an Express.Multer.File
. I kind of need it to be a multer file because we are also generating hashes from multer file buffer before we upload to our s3 storage. Using typescript I was coming up with something like this:
let imageResponse = await axios.get(imageURL, { responseType: "arraybuffer" });
let file: Express.Multer.File = {
buffer: Buffer.from(imageResponse.data, "binary"),
fieldname: "fieldname",
originalname: "imageName.jpg",
encoding: "binary",
mimetype: "image/jpg",
destination: __dirname,
}
I know this looks horribly wrong but yea I'm not sure how to tackle this.