Upload a file in S3

    0

    33

    awsboto3
    AWS and boto3 recipes for Python

    Your AWS access and secret keys must be stored as environment variables as specified in the boto documentation

    Library: boto3

    Shortcut: aws.s3

    import boto3
    
    def upload_file(local_path, remote_name):
      """
      Upload a file to S3
      :param local_path: local path to the file
      :param remote_name: path on the local bucket
      """
      client = boto3.client('s3',
                            region_name='aws_region', #AWS region
                            aws_access_key_id="access_key",
                            aws_secret_access_key="secret_key")
      client.upload_file(local_path, "bucket_name", remote_name)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.