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

Hi @Howard_Jennings ,

would you mind sharing the complete setup?

I am new to Make and I am trying to make an app (using appsmith) that can upload & download to and from FileCloud.
I finally managed to create a scenario to upload to filecloud from a webhook.
But I am still stuck with the download.

Would you mind sharing your entire setup? Also unsure how I should make the connections…

Hi @Gunther_Pelgrims this the the code for the “Download a folder or file” endpoint.

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

"headers": {
	"cookie": "{{parameters.cookie}}"
},
"response": {
	"type": "binary",
		"output": {
			"filename": "file_{{parameters.filename}}",
			"data": "{{body}}"
		}
}

These are the mappable parameters

[
{
“name”: “cookie”,
“type”: “text”,
“label”: “Cookie”,
“required”: false
},

{
	"name": "filepath",
	"type": "text",
	"label": "Path",
	"required": true
},
{
	"name": "filename",
	"type": "text",
	"label": "File Name",
	"required": false
}

]

To run this you first need to be logged in as a user to populate the “Cookie” parameter. We use our FileCloud as a client portal and only grant our users Guest logins. This means that all of the automations we run can be done with the same full user login which makes it much simpler. It also means we can easily control what our users can do. We have around 2000 guest users.