title: How to upload an in memory file data to google cloud storage using nodejs?
body: <p>I am reading an image from a url and processing it. I need to upload this data to a file in cloud storage, currently i am writing the data to a file and uploading this file and then deleting this file. Is there a way i can upload the data directly to the cloud stoage?</p>
  <pre><code>static async uploadDataToCloudStorage(rc : RunContextServer, bucket : string, path : string, data : any, mimeVal : string | false) : Promise&lt;string&gt; {
    if(!mimeVal) return ''
  
    const extension = mime.extension(mimeVal),
          filename  = await this.getFileName(rc, bucket, extension, path),
          modPath   = (path) ? (path + '/') : '',
          res       = await fs.writeFileSync(`/tmp/${filename}.${extension}`, data, 'binary'),
          fileUrl   = await this.upload(rc, bucket, 
                              `/tmp/${filename}.${extension}`,
                              `${modPath}${filename}.${extension}`)
                     
    await fs.unlinkSync(`/tmp/${filename}.${extension}`)
  
    return fileUrl
  }
  
  static async upload(rc : RunContextServer, bucketName: string, filePath : string, destination : string) : Promise&lt;string&gt; {
    const bucket : any = cloudStorage.bucket(bucketName),
          data   : any = await bucket.upload(filePath, {destination})
  
    return data[0].metadata.name
  }
  </code></pre>