title: Firebase cloud function for file upload
body: <p>I have this cloud function that I wrote to upload file to google cloud storage:</p>
  
  <pre><code>const gcs = require('@google-cloud/storage')({keyFilename:'2fe4e3d2bfdc.json'});
  
  var filePath = file.path + "/" + file.name;
  
      return bucket.upload(filePath, {
          destination: file.name
      }).catch(reason =&gt; {
              console.error(reason);
      });
  </code></pre>
  
  <p>I used <code>formidable</code> to parse the uploaded file and I tried to log the properties of the uploaded file and it seems fine; it is uploaded to a temp dir <code>'/tmp/upload_2866bbe4fdcc5beb30c06ae6c3f6b1aa/</code> but when I try to upload the file to the gcs am getting this error: </p>
  
  <pre><code>{ Error: EACCES: permission denied, stat '/tmp/upload_2866bbe4fdcc5beb30c06ae6c3f6b1aa/thumb_ttttttt.jpg'
      at Error (native)
    errno: -13,
    code: 'EACCES',
    syscall: 'stat',
    path: '/tmp/upload_2866bbe4fdcc5beb30c06ae6c3f6b1aa/thumb_ttttttt.jpg' }
  </code></pre>
  
  <p>I am using this html form to upload the file: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;form action="https://us-central1-appname.cloudfunctions.net/uploadFile" method="post" enctype="multipart/form-data"&gt;
      Select image to upload:
      &lt;input type="file" name="fileToUpload" id="fileToUpload"&gt;
      &lt;input type="submit" value="Upload Image" name="submit"&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>