Hi @evaldas Thanks for the solution.
Here is what I have tried: Reading and encoding a file. It works.
const axios = require('axios'); // For making HTTP requests.
exports.main = async (event, callback) => {
try {
// Example: Get contact properties from the event
const contactId = event.object.objectId;
const contactEmail = event.inputFields['email'];
const file = event.inputFields['uploadedFile'];
const response = await axios.get(file, {
responseType: 'arraybuffer',
});
const base64Image = Buffer.from(response.data, 'binary').toString('base64');
// Payload to send to the external system
const payload = {
id: contactId,
email: contactEmail,
filename: "uploaded-image.png", // Replace with desired file name.
filetype: "image/png", // Replace with the correct MIME type if different.
content: base64Image, // Base64 encoded content.
};
callback({
outputFields: {
status: "Success",
payload: payload,
},
});
} catch (error) {
console.error("Error posting data: ", error);
// Return error response
callback({
outputFields: {
status: "Error",
message: error.message,
},
});
}
};