title: How to read and write to a .txt file located on a s3 bucket?
body: <p>I have a challenge that asks me to update the number inside a .txt file with the next prime number. The problem is that it must be updated inside an s3 bucket, and I really don't know how to read/write inside a file in s3 using nodeJS. I'm using a Lambda function to do it.</p>
  
  <p>I tried to search inside AWS SDK S3 documentation to get some input but didn't have success. I'm new to cloud so I'm struggling to understand some 
  concepts.</p>
  
  <p>I used fs to read/write to a local file:</p>
  
  <pre class="lang-js prettyprint-override"><code>var fs = require("fs");
  
  var calculateNextPrime = function (currentNumber) {
      var divisor = 0;
      var isTrue = false;
      currentNumber++;
  
      while (isTrue === false) {
          for (var i = 1; i &lt;= currentNumber; i++) {
              if (currentNumber % i === 0) {
                  divisor++;   
              }
          }
          if (divisor === 2) {
              isTrue = true;
          } else {
              currentNumber += 1;
              divisor = 0;
  
          }
      }
      return currentNumber;
  }
  
  
  var fileContent = fs.readFileSync('file.txt', 'utf8');
  fileContent = Number(fileContent);
  
  var newFileContent = insertNextPrime(fileContent);
  fs.writeFileSync('file.txt', newFileContent);
  </code></pre>