size_objects(path: Union[str, List[str]], wait_time: Optional[Union[int, float]] = None, use_threads: bool = True, boto3_session: Optional[boto3.session.Session] = None) → Dict[str, Optional[int]]¶
Get the size (ContentLength) in bytes of Amazon S3 objects from a received S3 prefix or list of S3 objects paths.
In case of use_threads=True the number of threads that will be spawned will be get from os.cpu_count().
path (Union[str, List[str]]) – S3 prefix (e.g. s3://bucket/prefix) or list of S3 objects paths (e.g. [s3://bucket/key0, s3://bucket/key1]).
wait_time (Union[int,float], optional) – How much time (seconds) should Wrangler try to reach this objects. Very useful to overcome eventual consistence issues. None means only a single try will be done.
use_threads (bool) – True to enable concurrent requests, False to disable multiple threads. If enabled os.cpu_count() will be used as the max number of threads.
boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.
Dictionary where the key is the object path and the value is the object size.
- Return type
>>> import awswrangler as wr >>> sizes0 = wr.s3.size_objects(['s3://bucket/key0', 's3://bucket/key1']) # Get the sizes of both objects >>> sizes1 = wr.s3.size_objects('s3://bucket/prefix') # Get the sizes of all objects under the received prefix >>> sizes2 = wr.s3.size_objects('s3://bucket/prefix', wait_time=30) # Overcoming eventual consistence issues