title: Google Cloud Functions bucket.upload()
body: <p>I'm trying to archive pdf files from remote websites to Google Cloud Storage using a google function triggered by a firebase write. </p>
  
  <p>The code below works. However, this function copies the remote file to the bucket root. </p>
  
  <p>I'd like to copy the pdf to the pth of the bucket: <code>library-xxxx.appspot.com/Orgs/${params.ukey}</code>. </p>
  
  <p>How to do this?</p>
  
  <pre><code>exports.copyFiles = functions.database.ref('Orgs/{orgkey}/resources/{restypekey}/{ukey}/linkDesc/en').onWrite(event =&gt; {
      const snapshot = event.data;
      const params = event.params;
      const filetocopy = snapshot.val();
      if (validFileType(filetocopy)) {
          const pth = 'Orgs/' + params.orgkey;
  
          const bucket = gcs.bucket('library-xxxx.appspot.com')
          return bucket.upload(filetocopy)
              .then(res =&gt; {
              console.log('res',res);
              }).catch(err =&gt; {
              console.log('err', err);
          });
      }
  });
  </code></pre>