A.Adex
A.Adex

Reputation: 1

using python boto to copy json file from my local machine to amazon S3

I have a json file with file name like '203456_instancef9_code323.json' in my C:\temp\testfiles directory and want to copy the file to Amazon s3 bucket and my bucket name is 'input-derived-files' using python and boto library but throwing exceptions at all times saying the file does not exist.I have a valid access id and secret key and could establish connection to AWS. Could someone help me with the best code to script for this please. Many thanks for your contribution

Upvotes: 0

Views: 745

Answers (1)

user1811107
user1811107

Reputation: 759

Here is the code that you need based on boto3, it is the latest boto library and is maintained. You need to make sure that you use the forward slash for directory path. I have tested this code on windows and it works.

import boto3

s3 = boto3.resource('s3')

s3.meta.client.upload_file('C:/temp/testfiles/203456_instancef9_code323.json', 
'input-derived-files', '203456_instancef9_code323.json')

Upvotes: 1

Related Questions