class_docstr: S3Payload class
class_docstr_tok: ["S3Payload","class"]
docstr: Download and read the contents of the S3 file
  
  Yields:
      tuple: line number, contents of the line being read
docstr_tok: ["Download","and","read","the","contents","of","the","S3","file","Yields",":","tuple",":","line","number",",","contents","of","the","line","being","read"]
code: def _read_file(self):
      """Download and read the contents of the S3 file
  
      Yields:
          tuple: line number, contents of the line being read
      """
      bucket = self._unquote(self.bucket)
      key = self._unquote(self.key)
  
      # Use tempfile.TemporaryFile to do the download
      # This will automatically close/get garbage collected upon completion
      with tempfile.TemporaryFile() as download:
          client = boto3.resource("s3", region_name=self.region).Bucket(
              bucket
          )
          start_time = time.time()
          LOGGER.info(
              "[S3Payload] Starting download from S3: %s/%s [%s]",
              bucket,
              key,
              self.size,
          )
  
          try:
              client.download_fileobj(key, download)
          except (IOError, ClientError):
              LOGGER.exception("Failed to download object from S3")
              raise
  
          total_time = time.time() - start_time
          LOGGER.info(
              "Completed download in %s seconds", round(total_time, 2)
          )
  
          # Log a metric on how long this object took to download
          MetricLogger.log_metric(
              FUNCTION_NAME, MetricLogger.S3_DOWNLOAD_TIME, total_time
          )
  
          for line_num, line in self._read_downloaded_object(download):
              yield line_num, line
  
          # Reading was a success, so truncate the file contents and return
          download.seek(0)
          download.truncate()
  
imports: import json
  import logging
  import urllib.request
  import urllib.parse
  import urllib.error
  import gzip
  import os
  import tempfile
  import subprocess
  import time
  import boto3
  from botocore.exceptions import ClientError
  import jsonlines
  from streamalert.classifier.payload.payload_base import PayloadRecord, RegisterInput, StreamPayload
  from streamalert.shared import CLASSIFIER_FUNCTION_NAME
  from streamalert.shared.logger import get_logger
  from streamalert.shared.metrics import MetricLogger
label_desc: Use image node_id 13 for calling the S3Payload obj's underlying member method code with example usage: obj._read_file() without return types