REMINDER
CloudBackEnd DownloadFile
-
Hi Team,
Im trying to download a file using appdrag-cloudbackend. As indicated in the documentation, i've done all the steps and getting the success response. But still the file is not downloaded.
My app.js
$('#getDownloadFile').on('click', function(){
fetch('https://*****.appdrag.site/api/downloadFile',{
method: 'GET',
}).then(res=>{
console.log('successfully sent');
console.log(res);
return res;
}).catch(err=>console.log(err.message));
});My CloudBackend function
var cloudbackend = require('appdrag-cloudbackend');
// INIT FROM CODE VARIABLES
cloudbackend.init('your_api_key', 'your_app_id');
// INIT FROM ENVIRONMENT VARIABLES
cloudbackend.init(process.env.APIKEY, process.env.APPID);exports.handler = async (event, context, callback) => {
cloudbackend.downloadRemoteFile("https://s3-eu-west-1.amazonaws.com/dev.appdrag.com/*****/CloudBackend/files/66dc8825-7c34-4b71-914b-ec85393caebc.txt", "test.txt").then( function(response) {
return response;
});
};My log messages
successfully sent
Response {type: "basic", url: "https://*****.appdrag.site/api/downloadFile", redirected: false, status: 200, ok: true, …}body: (...)bodyUsed: falseheaders: Headers {}ok: trueredirected: falsestatus: 200statusText: ""type: "basic"url: "https://****.appdrag.site/api/downloadFile"proto: ResponseWhat am i missing to make the download happen ?
-
Instead of calling the download with fetch, from the client side just make a A Link pointing to the url of your cloud function
You can also check our NodeJS samples to return a binary file