title: Heroku nodejs pathing issue... Error: ENOENT: no such file or directory
body: <p>I have a nodejs application using hapi.js and I'm trying to download an image from a url. Heroku is giving me errors with the pathing.</p>
  
  <p>My code:</p>
  
  <pre><code>Request(uri).pipe(fs.createWriteStream(__dirname+'/../public/images/'+filename)).on('close', callback);
  </code></pre>
  
  <p>My errors:</p>
  
  <pre><code> Error: ENOENT: no such file or directory, open '/app/../public/images/1430540759757341747_4232065786.jpg'
  </code></pre>
  
  <p>My file structure is simple:</p>
  
  <pre><code>app.js
  -public
   -images
    -sampleimage.jpg
   -videos
    -samplevideo.mp4
   -audio
    -sampleaudio.wav
  </code></pre>
  
  <p>As you can see the __dirname for heroku application is /app. I've tried using __dirname+'all sorts of pathing ../ ./ etc' and I've also tried it without __dirname.</p>
  
  <p>I will be creating a lot of these files using ffmpeg and a speech tool. So could anyone explain to me what kind of problem I am having? Is it something that can be solved by using the correct path name or is it my hapijs server configurations that I need to configure?</p>