Python Forum
Uploading a file to s3 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Uploading a file to s3 (/thread-31164.html)



Uploading a file to s3 - pisike - Nov-25-2020

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


RE: Uploading a file to s3 - pisike - Nov-30-2020

(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


RE: Uploading a file to s3 - bowlofred - Nov-30-2020

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.