title: Unable to read a saved file in heroku
body: <p>I am using NodeJS on heroku.</p>
  
  <p>I read a file from another server and save it into my application in the /temp directory.
  Next, I read the same file to pass it on to my client.</p>
  
  <p>The code that saves the file and then subsequently reads it is:</p>
  
  <pre><code>http.request(options, function (pdfResponse) {
      var filename = Math.random().toString(36).slice(2) + '.pdf',
          filepath = nodePath.join(process.cwd(),'temp/' + filename);
  
      pdfResponse.on('end', function () {
          fs.readFile(filepath, function (err, contents) {
              //Stuff to do after reading
          });
      });
  
      //Read the response and save it directly into a file
      pdfResponse.pipe(fs.createWriteStream(filepath));
  });
  </code></pre>
  
  <p>This works well on my localhost.</p>
  
  <p>However, when deployed to heroku, I get the following error:</p>
  
  <pre><code>events.js:72
  throw er; // Unhandled 'error' event
  Error: ENOENT, open '/app/temp/nvks0626yjf0qkt9.pdf'
  Process exited with status 8
  State changed from up to crashed
  </code></pre>
  
  <p>I am using <code>process.cwd()</code> to ensure that the path is correctly used. But even then it did not help. As per the heroku documentation, I am free to create files in the applications directory, which I am doing. But I can't figure out why this is failing to read the file...</p>