title: How to download file from Google Cloud Storage?
body: <p>I'm following up on this article to download objects from GCP Cloud storage bucket: <a href="https://cloud.google.com/storage/docs/downloading-objects#storage-download-object-nodejs" rel="nofollow noreferrer">https://cloud.google.com/storage/docs/downloading-objects#storage-download-object-nodejs</a></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const {Storage} = require('@google-cloud/storage');
  
  // Creates a client
  const storage = new Storage();
  
  async function downloadIntoMemory() {
    // Downloads the file into a buffer in memory.
    const contents = await storage.bucket(bucketName).file(fileName).download();
  
   return contents;
    );
  }
  
  downloadIntoMemory().catch(console.error);</code></pre>
  </div>
  </div>
  </p>
  <p>I'm currently getting a buffer data in <code>contents</code>. I've this code hooked upto a API on NodeJS backend. I'm using React Typescript on frontend. Calling the API, gives me data buffer. How can I use it to download the file instead of the data buffer?</p>
  <p>I tried the above method explicitly providing file destination, but I'm still getting the following error: EISDIR: illegal operation on a directory, open '{file_path_which_i_was_set}. Err: -21</p>