Accessing raw file data in Zapier JavaScript code

I’m working with file inputs in my Zapier integration and running into issues getting the actual file content. When I receive a file from services like Google Drive, the data comes in a hydrated format that looks like encoded text rather than the original file bytes.

const processFile = (z, bundle) => {
    const fileContent = bundle.inputData.file_input;
    
    function handleFile(content, processor, endpoint) {
        // Need to work with actual file bytes here
    }
}

module.exports = {
    operation: {
        inputFields: [
            {key: "processing_type", label: "Processing Type", choices: {cloud: 'Cloud', local: 'Local'}, required: true},
            {key: "file_input", label: "File Content", required: false}
        ],
        perform: processFile,
        sample: sampleData
    },
};

The file data I receive appears to be in some encoded format starting with “hydrate|||” followed by what looks like base64 or similar encoding. I need to extract the original file bytes so I can perform operations like generating checksums or hashes. Should I be using a dehydration process to convert this back to the raw file data? Any guidance on the proper approach would be helpful.

You’re encountering Zapier’s hydration system, which is designed to manage large files effectively. The “hydrate|||” prefix indicates that the file content has been dehydrated, and you will need to perform a separate fetch to get the actual file bytes.

To obtain the original file bytes, use the z.dehydrate() and z.request() methods. When you encounter content that begins with “hydrate|||”, extract the URL following the prefix and then make an HTTP request to retrieve the raw file data. I faced this issue when creating a document processing integration previously, and this approach was effective for generating checksums and processing files.

yeah zapier’s hydration is a pain. when u see that hydrate||| stuff, just use z.request() to get the real file data. i usually check if it starts with hydrate, then pull the url and make the req. worked well for my pdf processing last month.

The hydration system’s confusing at first. Here’s what worked for me: check for the hydrated format before processing anything. When you see the “hydrate|||” prefix, parse out the URL and use z.request() to grab the actual file content. Just check if it starts with that prefix, split on the delimiter to get the fetch URL. Handle the response properly since you’ll get the raw bytes needed for checksum operations. I had the same file integrity verification needs and this approach gave me the original file data without encoding headaches.