1 Answer
- Newest
- Most votes
- Most comments
0
A coworker of mine came up with a solution, had to create a custom class, some code snippets below for anyone who might want to implement similar functionality...
import boto3
import sys
class S3CopyProgress:
def __init__(self, objectSummary):
self.objectSummary = objectSummary
self.bytesTransferredTotal = 0
def updateProgress(self, bytesTransferred):
self.bytesTransferredTotal += bytesTransferred
percentComplete = round((self.bytesTransferredTotal/self.objectSummary.size)*100)
sys.stdout.write('[%s] %s%s of %s\r' % (self.objectSummary.key, percentComplete, '%', self.objectSummary.size))
sys.stdout.flush()
for line in prefixes:
myPrefix = line.rstrip()
print("*** Looking at prefix "+myPrefix+" ***")
objs = bucket.objects.filter(Prefix=myPrefix)
for objectSummary in objs:
key = objectSummary.key
if key.endswith("/"):
continue
progressMonitor = S3CopyProgress(objectSummary)
copy_source = {'Bucket': sourceBucket, 'Key':key}
s3.meta.client.copy(CopySource = copy_source, Bucket = destinationBucket, Key = key, Config = transferConfig, Callback = progressMonitor.updateProgress)
print("")
answered 5 years ago
Relevant content
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago