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.

    How to save uploaded file in Custom Folder ?

    Cloud Backend (Cloud DB, API Builder)
    2
    3
    405
    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,

      I'm trying to upload my file in custom folder path(uploadsFolder/) rather than default CloudBackEnd's upload folder. Below code is not working.

      Please guide me on how to achieve this

      My Folder Structure
      /
      CloudBackEnd
      uploadsFolder

      My Code
      var request = require('request');
      var cloudbackend = require('appdrag-cloudbackend');
      var appID = process.env.APPID; // Read from environment variables
      var APIKey = process.env.APIKEY; // Read from environment variables
      cloudbackend.init(APIKey, appID);
      exports.handler = (event, context, callback) => {

      var postedFiles = event["FILES"];
      
      if(postedFiles.length>0){
          for(i=0;i<postedFiles.length;i++){
              var tmpPath = postedFiles[i]["path"]; 
              var destPath = "uploadsFolder/"+ tmpPath;
              cloudbackend.fileSaveUploaded(tmpPath,destPath).then(callback(null, destPath));
          } // end -for
      }
      else {
          callback(null, postedFiles.length);
      }
      

      }; // end - handler

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

        Hey Vinoth,

        indeed you can write only inside /CloudBackend/uploads/
        But there you can write subfolders and files

        your code above will write in /CloudBackend/uploads/uploadsFolder/"+ tmpPath

        We might add later an option to be able to write at the root folder (/)

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

          @Joseph-Benguira

          Thanks Joseph. Also i have another doubt. What's the max file size we can upload in CloudBackEnd ?
          I tried to upload a file size of 55 mb. It doesn't worked.

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