title: File name issue in AWS lambda s3 file unzip python
body: <p>I have lambda function as below</p>
  
  <pre><code>from __future__ import print_function
  
  import urllib
  import zipfile
  import boto3
  import io
  import mimetypes
  
  import logging
  
  logger = logging.getLogger()
  logger.setLevel(logging.INFO)
  
  
  s3 = boto3.client('s3')
  bucket = 'staging-bucket'
  
  def lambda_handler(event, context):
      try:
          key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key'].encode('utf8'))
          obj = s3.get_object(Bucket=bucket, Key=key)
          with io.BytesIO(obj["Body"].read()) as tf:
              # rewind the file
              tf.seek(0)
              # Read the file as a zipfile and process the members
              with zipfile.ZipFile(tf, mode = 'r') as zipf:
                  for file in zipf.infolist():
                      fileName = file.filename
                      contentType, encoding = mimetypes.guess_type(fileName)
                      contentType = contentType or 'application/octet-stream'
                      filePath = "playable/staging/" + key.replace("package.zip", "") + fileName
                      putFile = s3.put_object(ACL = 'public-read', Bucket = "unzipped-bucket", Key = filePath, Body = zipf.read(file), ContentType = contentType)
  
  
      except Exception as e:
          logger.error('Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as this function.'.format(key, bucket))
          raise e
  
      return
  </code></pre>
  
  <p>It takes <strong>zip</strong> file from s3 bucket and extracts it to another s3 bucket</p>
  
  <p>the function runs successfully, but the extracted filename has the zip file name as prefix, see below pictures for reference </p>
  
  <p><strong><em>Source zip file :</em> package-1542108930.zip</strong></p>
  
  <p><strong><em>Source zip contents:</em></strong>
   <a href="https://i.stack.imgur.com/vG4vn.png" rel="nofollow noreferrer">source zip files</a></p>
  
  <p><strong><em>Extracted folder contents:</em></strong>
  <a href="https://i.stack.imgur.com/agiHi.png" rel="nofollow noreferrer">extracted files</a></p>
  
  <p>I'm unable to find the bug in python script, 
  any help will appreciated. Thanks in advance. </p>