is there a python code to find length of the file which is in S3 bucket

Below is the code snippet. appreciate inputs on this

s3_resource = boto3.resource('s3')
object_file = s3_resource.Object(bucket_name=bucket_name, key=object_key)
file_size=object_file.content_length
print("Size of the file being processed:".format(file_size))

This code code prints blank output every time I try to print the file size

Upvotes: 0

Views: 177

Answers (1)

jellycsc
jellycsc

Reputation: 12359

Change

print("Size of the file being processed:".format(file_size))

to

print("Size of the file being processed: {}".format(file_size))

Upvotes: 1

Related Questions