I'm trying to upload a local file via Boto set_contents_from_filename(). I followed the tutorial instructions here but no luck. I also tried variations mentioned in StackOverflow here and here but I get the same error.
Any attempt calling set_contents_from_filename gives "FileNotFoundError: [Errno 2] No such file or directory"
My python script is in the same subdir as the file I want to upload: AWS_Upload.txt. My working directory is also set correctly. I can successfully call set_contents_from_string() so I know everything else works (my keys, my bucket, etc.)
Also, the FILE_PATH constants below are left over from trying the os.path.join to create a proper full path, but I received the same error.
Lastly, the file really does exist. I copy and paste c:\Apps\Docs\Python\MyPy\AWS_Upload.txt into Windows File Explorer and the file appears in Notepad.
Any help would be appreciated.
from boto.s3.key import Key
import boto.sqs
ACCESS_KEY='mykey'
SECRET_ACCES_KEY='mysecret'
BUCKET = 'pybucket234'
FILE_PATH = 'c:\\Apps\\Docs\\Python\\MyPy\\'
FILE_UPLOAD = 'AWS_Upload.txt'
conn = boto.connect_s3(aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_ACCES_KEY)
# Save some data
bucket = conn.get_bucket(BUCKET)
k = Key(bucket)
k.key = 'myfilekey'
k.set_contents_from_filename('AWS_Upload.txt')
# FileNotFoundError: [Errno 2] No such file or directory: 'AWS_Upload.txt'
# Tried this as well but get the same error
k.set_contents_from_filename('c:\Apps\Docs\Python\MyPy\AWS_Upload.txt')
# FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Apps\\Docs\\Python\\MyPy\\AWS_Upload.txt'