title: error sending multiple files to aws s3 using python
body: <p>I'm learning about AWS IoT using Raspberry Pi and python. Problem I came across is the following:</p>
  
  <p>In main function on event detection a picture is been taken and saved on the Pi. After picture is saved a function store_to_bucket is called and i'm passing two parameters: a path, where picture is stored and a date string. Everything is working fine for the first time. Second function call gives me the following error:</p>
  
  <p>ClientError: An error occurred (AuthorizationHeaderMalformed) when calling the PutObject operation: The authorization header is malformed; a non-empty Access Key (AKID) must be provided in the credential.</p>
  
  <p>Code </p>
  
  <pre><code>ACCESS_KEY_ID   =   open("/mykey/path/key.txt", "r")
  ACCESS_SECRET_KEY = open("/mykey/path/skey.txt", "r")
  BUCKET_NAME =   open("/mykey/path/bucket.txt", "r").read()
  
  data = open(path, 'rb') 
      ext = '.jpg'    
  
  s3 = boto3.resource(
      's3',
      aws_access_key_id=ACCESS_KEY_ID.read(),
      aws_secret_access_key=ACCESS_SECRET_KEY.read(),
      config=Config(signature_version='s3v4')
  )
  
  def store_to_bucket(path, date):
      s3.Bucket(BUCKET_NAME).put_object(Key=date+ext, Body=data)
      print ("Done")
  </code></pre>
  
  <p>Not sure what the problem is with credentials? Has anyone experienced similar issue or knows how to fix it?</p>
  
  <p>Found solution to my problem by fixing some code. UPdated version below:</p>
  
  <pre><code>import boto3
  from botocore.client import Config
  
  ACCESS_KEY_ID = open("/home/pi/Desktop/pythonForAWS/certs/key.txt", 
  "r").read()
  
  ACCESS_SECRET_KEY = open("/home/pi/Desktop/pythonForAWS/certs/skey.txt", 
  "r").read()
  
  BUCKET_NAME = open("/home/pi/Desktop/pythonForAWS/certs/bucket.txt", 
  "r").read()
  
  def store_to_bucket(path, date):
  
      data = open(path, 'rb')
      ext = '.jpg'    
  
      s3 = boto3.resource(
          's3',
           aws_access_key_id=ACCESS_KEY_ID,
           aws_secret_access_key=ACCESS_SECRET_KEY,
           config=Config(signature_version='s3v4')
      )
  
      s3.Bucket(BUCKET_NAME).put_object(Key=date+ext, Body=data)
  
      print ("Done")
  </code></pre>