title: Move a file from one folder to another folder in s3
body: <p>First I'm trying to copy the file into other folder and unable to delete it. How I can delete the file only if the file is copied to the destination folder.</p>
  
  <pre><code>    const s3Params = {
          Bucket: bucket,
          CopySource: bucket + '/' + objectkey,
          Key: 'processed-data/' + objectkey
      };
  
      function copyFile() {
          s3.copyObject(s3Params, function (err, data) {
              if (err) {
                  console.log(err);
              }
              else {
                  deleteFile();
              }
          });
      }
  
      function deleteFile() {
          s3.deleteObject(s3Params, function (err, data) {
              if (err) {
                  console.log(err, err.stack);
                  logs.push(err, err.stack);
              }
              else {
                  console.log("File moved successfully");
                  log.push("File moved successfully");
              }
          });    
      }
  </code></pre>