Is Workflow Webhook Response with File attachment possible?

I have a workflow I am downloading a file from an S3 resource. It comes back as this object:

{
"data": {
"Metadata": {},
"LastModified": "2024-11-14T18:33:49.000Z",
"ContentLength": 21,
"ContentType": "binary/octet-stream",
"AcceptRanges": "bytes",
"ETag": ""9TESTETAG6"",
"Key": "test/testing/default.txt",
"Body": "H3oiQk44wrdAw7Qlw67DhSvDoHwn",
"IsJson": false
}
}

I have a Webhook return on a 200 returning 'download_file.data' which returns this object:

{
"data": {
"status": 200,
"body": {
"Metadata": {},
"LastModified": "2024-11-14T18:33:49.000Z",
"ContentLength": 21,
"ContentType": "binary/octet-stream",
"AcceptRanges": "bytes",
"ETag": ""9TESTETAG6"",
"Key": "test/testing/default.txt",
"Body": "H3oiQk44wrdAw7Qlw67DhSvDoHwn",
"IsJson": false
}
}
}

This entire workflow is setup as a webhook, so when I call this in Postman, the response I get instead of downloading a text file with the data is a response.json file.

Could you assist with getting this formatted to return the file correctly so the web response recognizes it as an attachment? I didn't see a way to access/modify the response headers to force it

Hello @dohrann,

To clarify, when you run a Postman request to your s3 bucket does that return a text file as an attachment?

There are some configuration steps outside of Retool that must be followed to get the response to be a file attachment, as well as other set up steps to download this attached file upon receiving this from the AWS s3 bucket.

I haven't tried to replicate this behavior in Retool myself, I can check with our engineering team to confirm that this use case is something that Retool workflows is able to execute.

As you mentioned there needs to be a high level of specificity in the request being made to ensure the response is what you want it to be. If we do not have this I can make a feature request to add in better support for this functionality!

Just for clarification, these are the steps I found for setting up AWS s3 to return a file as an attachment and to download it.

These are the steps from for a web app so there are likely steps that are abstracted away by Retool that may need to be exposed to users.

Set the Correct Headers:

  • ensure you don’t explicitly set the Accept header to application/json

Adjust the Backend Configuration

If the server is responding with JSON instead of the file, verify:

  • Content Disposition: The object in S3 should be served with a Content-Disposition header set to attachment. You can set this when uploading the file to S3:
const params = {
    Bucket: 'your-bucket',
    Key: 'your-key',
    Body: fileStream,
    ContentDisposition: 'attachment',
};
s3.upload(params, (err, data) => {
    if (err) console.log('Error:', err);
    else console.log('Upload success:', data);
});

If you want to trigger a download in the browser:

const link = document.createElement('a');
link.href = 'https://your-s3-file-url';
link.download = 'filename.ext'; // Optional filename
document.body.appendChild(link);
link.click();
document.body.removeChild(link);

Just heard back from one of our engineers.

They said for triggering a workflow that needs to process a file, you'd instead send a handle of the file or a pre-signed url through the params.

Same for the response of that webhook workflow.

Only json is supported for webhook response blocks.