Canonize instance of class boto3 S3Transfer

Trying to configure 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 resolves correctly 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

+5
source share
1 answer

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

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

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

+9
source

Source: https://habr.com/ru/post/1243092/


All Articles