title: To upload a file to amazon s3 using lambda
body: <p>I used this python code to upload file to s3 bucket using lambda. Getting an error:</p>
  <pre><code>{
    &quot;errorMessage&quot;: &quot;Syntax error in module 'lambda_function': (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \\UXXXXXXXX escape (lambda_function.py, line 10)&quot;,
    &quot;errorType&quot;: &quot;Runtime.UserCodeSyntaxError&quot;,
    &quot;stackTrace&quot;: [
      &quot;  File \&quot;/var/task/lambda_function.py\&quot; Line 10\n        file_name= \&quot;C:\\Users\\smanthriprag\\Pictures\\Screenshots\\s.jpeg\&quot;\n&quot;
    ]
  }
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>import json
  import boto3
  
  
  from botocore.exceptions import ClientError
  
  
  def lambda_handler(file_name, bucket, object_name=None):
      
      file_name= &quot;C:\Users\smanthriprag\Pictures\Screenshots\s.jpeg&quot;
      bucket= &quot;serverlesswebapp0406&quot;
  
      # If S3 object_name was not specified, use file_name
      if object_name is None:
          object_name = file_name
  
      # Upload the file
      s3_client = boto3.client('s3')
      try:
          response = s3_client.upload_file(file_name, bucket, object_name)
          print('Step 3: upload done')
      except ClientError as e:
          logging.error(e)
          return False
      return True['response']
  </code></pre>