I am researching for a way to export a file from our application into another app like Google Drive. However I’m running into some difficulty hydrating the file or making it a file object as described in https://help.zapier.com/hc/en-us/articles/8496259603341#file-fields-0-4.
In my action step using the code below I’m taking a encoded file from our database and doing a base64 decode to get the file name, file type, the buffer stream, and buffer stream length.
const encodedFile = bundle.inputData.file;
const decodedFile = Buffer.from(encodedFile, 'base64').toString('utf-8');
var fileByte = Buffer.from(decodedFile.substring(decodedFile.indexOf('<File>')+6,decodedFile.indexOf('</File>')), 'base64').toString('utf-8');
var filetype =Buffer.from(decodedFile.substring(decodedFile.indexOf('<FileType>')+10,decodedFile.indexOf('</FileType>')), 'base64').toString('utf-8');
var filename = Buffer.from(decodedFile.substring(decodedFile.indexOf('<UploadedFileName>')+18,decodedFile.indexOf('</UploadedFileName>')), 'base64').toString('utf-8');
//Buffer.from(decodedFile.substring(decodedFile.indexOf('<File>')+6,decodedFile.indexOf('</File>')), 'base64').toString('utf-8')
//output = { type: filetype, name: filename, file: fileByte };
return {'myFile':z.stashFile(fileByte,fileByte.length,filename,'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')};
Unfortunately the result is an empty value.
I’m looking for some guidance on this as there doesn’t appear to be a lot of documentation or examples showing how to display the files in hydrated format and since files are in the database there isn’t a public url available to pull the file from.