Navigation

    APPDRAG Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular

    REMINDER

    Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

    CloudBackEnd DownloadFile

    Cloud Backend (Cloud DB, API Builder)
    2
    2
    202
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • vinoth kumar
      vinoth kumar last edited by

      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: Response

      What am i missing to make the download happen ?

      1 Reply Last reply Reply Quote 0
      • Joseph Benguira
        Joseph Benguira last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post