How to setup a download module that returns a file

I’m building a new module for a custom app I’ve built for FileCloud. I’m trying to add the download a file endpoint. I can get it to run without errors, but I can’t get any output. I need something in the “response” line, but I’ve no idea what to put. I’ve tried using the same code as all the other modules I’ve built, but nothing helps. Can anyone help?

This is the link to the FileCloud API docs:

https://fcapi.filecloud.com/#/file/downloadfile

This is my code. The connection and params etc. are all good. It’s just the response code I need.

{
“url”: “/core/downloadfile”,
“method”: “GET”,
“qs”: {
“filepath”: “{{parameters.filepath}}”,
“filename”: “{{parameters.filename}}”,
“checkonly”: false
},

"headers": {
	"cookie": "{{parameters.cookie}}"
},
"response": {
	"output": "{{data}}"

}

}

HI @Howard_Jennings,

There are a few things that need to be changed, Based on the API document(from which I am not quite clear what the response looks like), but based on the assumption that it returns binary data, what you can do is change your module setup to,

"response": {
			"type": "binary",
			"output": {
			    "fileSize": "{{headers.`content-length`}}",
				"filename": "{{replace(replace(headers.`content-disposition`,'inline; filename=',''),'\"','')}}",
				"data": "{{body}}"
			}
		}

And, In the Interface add this,

[
    {
        "name": "data",
        "type": "buffer",
        "label": "Data",
        "semantic": "file:data"
    },
    {
        "name": "fileName",
        "label": "File Name",
        "type": "text",
        "semantic": "file:name"
    },
    {
        "name": "fileSize",
        "label": "File Size",
        "type": "uinteger"
    }
]
1 Like