title: compress .txt file on s3 location to .gz file
body: <p>I need to compress a .txt-  file to .gz which is on S3 location and then upload it to a different S3 bucket. I have written following code but its not working as expected:</p>
  <pre><code>def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'):
  
      with gzip.GzipFile(fileobj=compressed_fp, mode='wb') as gz:
          shutil.copyfileobj(fp, gz)
      compressed_fp.seek(0)
      print(compressed_fp)
  
      bucket.upload_fileobj(
          compressed_fp,
          key,
          {'ContentType': content_type, 'ContentEncoding': 'gzip'})
  
  source_bucket = event['Records'][0]['s3']['bucket']['name']
  file_key_name = event['Records'][0]['s3']['object']['key']
  
  response = s3.get_object(Bucket=source_bucket, Key=file_key_name)
  original = BytesIO(response['Body'].read())
  original.seek(0)
  
  upload_gzipped(source_bucket, file_key_name, original)
  </code></pre>
  <p>Can someone please help here, or any other approach to gzip the file on S3 location</p>