Python Forum

Full Version: Uploading a file to s3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying the below to upload a file to s3. I a, using python 2.7.

import boto3
from botocore.exceptions import NoCredentialsError
ACCESS_KEY = 'xxxxxxxxxxxxxx'
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
def upload_to_aws(local_file, bucket, s3_file):s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,aws_secret_access_key=SECRET_KEY)
#try:s3.upload_file(local_file, bucket, s3_file)
upload_to_aws('C:\Users\test_2_fields.csv', 'test-bukcet-aws', '/tmpload/test_2_fields.csv')

I am running into syntax error. can you please suggest what's wrong
(Nov-25-2020, 08:42 PM)pisike Wrote: [ -> ]I am trying the below to upload a file to s3. I a, using python 2.7.

import boto3
from botocore.exceptions import NoCredentialsError
ACCESS_KEY = 'xxxxxxxxxxxxxx'
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
def upload_to_aws(local_file, bucket, s3_file):s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,aws_secret_access_key=SECRET_KEY)
#try:s3.upload_file(local_file, bucket, s3_file)
upload_to_aws('C:\Users\test_2_fields.csv', 'test-bukcet-aws', '/tmpload/test_2_fields.csv')

I am running into syntax error. can you please suggest what's wrong

I am getting syntax error. This is the whole code I have
Use python tags around your code (or the python button above the editor). Can't see the indentation otherwise. You haven't shown us the (complete) error message either

You shouldn't have anything on the same line after the colon on the "def" line. Looks like two lines got joined that shouldn't be.