Skip to main content

Hello community members, 

I am trying to implement a file input to zapier when a new item is added. The response receives a base64 encoded text in utf-8. I need to convert this into file such that while creating zaps I can add a file. (Similar to attachments in Gmail trigger).

I am implementing it in trigger while I am modifying the parse function as follows:

async function getFile(file_data) {
const encoded_file = file_data.upload_file;
var file_byte = Buffer.from(encoded_file, 'base64');
const stashFile = await z.stashFile(file_byte, file_byte.length, file_data.file_name, file_data.mime_type);
return stashFile
}

The file_data is dictionary with following definition example:

{

“file_name”: “Name.png”,

“upload_file”: “iVBourofdsnf9er/gas//codof-==”

“mime_type”: “image/png”

}

 

It shows following error:

error message

 

What are the definitions of create or hydration function?

Hi @Tirth Shah,

The reason for that error message is because you have specified file stashing outside a create or a hydrator function.

We do have an example app that shows how to set up an integration that works with files: https://github.com/zapier/zapier-platform/tree/main/example-apps/files

I would advise you to look at the hydrators.js and the triggers > newFile.js files for guidance.

Hope that helps?
 

All the best,


Reply