const imageResponse = await axios.get(url[0], {
responseType: "arraybuffer",
});
const buffer = Buffer.from(imageResponse.data, "utf-8");
const image = Media.addImage(doc, buffer);
I'm using the above code inside one loop that will execute 100 times because it has 100 images. Each image size is max 150kb. I deployed the cloud function with 256mb. I'm getting "Error: memory limit exceeded. Function invocation was interrupted".
Problem statement:
I need to add 250 images in word document. I'm getting memory limit exceeded error.
Q&A
Is there any way to get one image and add to word document, after that clearing the memory used by the image?
How to effectively use this plugin in firebase cloud function with cloud storage for images?
Environment:
Firebase Cloud Function (NodeJs)
Size : 256mb
Word Doc Generating Library : docx (https://docx.js.org/#/)