message: Stream files directly from GCS instead of buffering and sending.
diff: @@ -169,30 +169,23 @@ export class GoogleGCSPublish implements PublisherBase {
  // Files with different extensions (CSS, HTML) need to be served with different headers
  const fileExtension = path.extname(filePath);
  const responseHeaders = getHeadersForFileExtension(fileExtension);
  + res.writeHead(200, {
  + ...{
  + 'Transfer-Encoding': 'chunked',
  + },
  + ...responseHeaders,
  + });
  - const fileStreamChunks: Array<any> = [];
  + // Pipe file chunks directly from storage to client.
  this.storageClient
  .bucket(this.bucketName)
  .file(filePath)
  .createReadStream()
  .on('error', err => {
  this.logger.warn(err.message);
  - res.status(404).send(err.message);
  - })
  - .on('data', chunk => {
  - fileStreamChunks.push(chunk);
  + res.destroy(err);
  })
  - .on('end', () => {
  - const fileContent = Buffer.concat(fileStreamChunks);
  - // Inject response headers
  - for (const [headerKey, headerValue] of Object.entries(
  - responseHeaders,
  - )) {
  - res.setHeader(headerKey, headerValue);
  - }
  -
  - res.send(fileContent);
  - });
  + .pipe(res);
  };
  }
  