I am using Astro to send a file that the client uploads to the company email
In the content part of the file, how do I pass a file buffer to it?
if(Astro.request.method === 'POST'){
const formData = await Astro.request.formData()
const file = formData.get('file')
const { email } = await UserModel.profile({ id: user.id })
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: import.meta.env.EMAIL,
pass: import.meta.env.EMAIL_PASSWORD,
},
});
const mailOptions = {
from: email,
to: import.meta.env.EMAIL,
subject: 'Payment ' + email,
attachments: [
{
filename: file.name,
content: ?????????
contentType: file.type
}
]
};
transporter.sendMail(mailOptions, (error) => {
if (error) return error = 'Error al enviar el mensaje'
return Astro.redirect('/')
});
}
console.log(file) show:
File {
size: 262812,
type: 'application/pdf',
name: 'name.pdf',
lastModified: 1719289688034
}