The best answer to this lives in our CLI docs:
zapier init . --template=files
in Terminal to see it in your local code editor.
index.js
, hydrators.js
, triggers/newFile.js
, and creates/uploadFile.js
.
When building your integration, you’ll likely be retrieving file info from a remote server. Instead, this example integration hard codes file urls to demonstrate.
The New File
Trigger returns those file urls. The method z.dehydrateFile
is used to create a pointer to the downloadFile
function. In order to pass those files to other apps in actions, we reference hydrators.downloadFile
, our hydrating function given a file url.
If you look at the hydrators.js
file, you can see the downloadFile
function. downloadFile
calls the methodz.stashFile
to return a URL file pointer.
All of these will work together to lazily fetch the trigger data only when needed, avoiding API calls during polling or for reuse.
The only Action for this app is to upload the file, given a bundle.inputData.file
.
zapier init . --template=files
and zapier push
it to Zapier. If you’ve not worked with the CLI before, start by checking out the tutorial.
Test trigger
to see the three sample urls pulled in and hydrated pointer for each.
Upload File
action to the Zap. Normally, we wouldn’t want a setup like this (trigger off of new file / create a new file), because it would result in a Zap loop. But this is just a test—and be sure to turn the Zap off shortly after it’s turned on.
Test step
, you will see three new requests show in the Monitoring
tab of your integration:
fileURLs
in the trigger perform
, with a request to your API that returns the triggering file, you’ll be able to test this out fully.