Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canot instantiate boto3 S3Transfer class

Trying to set up boto3 S3Transfer according to AWS docs:

import boto3
client = boto3.client('s3', 'us-east-1')
transfer = S3Transfer(client)

Result:

NameError: name 'S3Transfer' is not defined

Tried Python 2.7.11 and 3.5.1 (MacOS), same result. boto3 is installed and properly resolves in my IDE (IntelliJ):

Successfully installed boto3-1.2.3 botocore-1.3.26 docutils-0.12 futures-3.0.5 jmespath-0.9.0 python-dateutil-2.4.2

Any pointers would be appreciated.

Thanks, Ron

like image 547
Ron Cohen Avatar asked Feb 15 '16 22:02

Ron Cohen


1 Answers

The S3Transfer class is in the module boto3.s3.transfer so you have to do something like this:

from boto3.s3.transfer import S3Transfer
import boto3

client = boto3.client('s3')
transfer = S3Transfer(client)

Note the import statement above. Also note that the S3Transfer methods are already integrated into the S3 client and S3 resource so you may not need to access it directly.

like image 170
garnaat Avatar answered Oct 20 '22 02:10

garnaat