In a smart action with a form that has a enum , the user selects an option and execute the action, after data is fetched I want to download a file from a remote url (a cloudinary hosted file) and return the downloaded file as a response
Actual behavior
Not returning the file
Failure Logs
I could not find any documentation about how to do this
Context
//rest of the code in users collection
{
name: "Download User Documents",
type: "single",
fields: [
{
field: 'Download User Documents',
description: 'Select Document Type',
type: 'Enum',
isRequired: true,
enums: [
"Carta del Banco",
"Certificado de Proyecto de Trabajo",
"Certifico de No Adeudo Fiscal",
],
}
]
},
...//rest of the code
// Get the values of the input fields entered by the admin user.
const attrs = req.body.data.attributes.values;
let selected_document = attrs['Download User Documents'];
console.log("selected document ", selected_document);
//Logic where I calculate the right file and get the url
res.sendFile(fileName, options, (error) => {
if (error) { next(error); }
//HOW TO SEND THE FILE BACK IF I ONLY HAVE AN EXTERNAL URL??
});
// res.send({ success: "Accion exitosa selected_document " + selected_document })
});
Expected behavior
In a smart action with a form that has a enum , the user selects an option and execute the action, after data is fetched I want to download a file from a remote url (a cloudinary hosted file) and return the downloaded file as a response
Actual behavior
Not returning the file
Failure Logs
I could not find any documentation about how to do this
Context
router.post('/actions/download-user-documents', permissionMiddlewareCreator.smartAction(), (req, res) => {
//Logic where I calculate the right file and get the url
//HOW TO SEND THE FILE BACK IF I ONLY HAVE AN EXTERNAL URL?? }); // res.send({ success: "Accion exitosa selected_document " + selected_document }) });