Move Module

Move S3 objects.

s3_tools.move.move_keys(source_bucket: str, source_keys: List[str], destination_bucket: str, destination_keys: List[str], threads: int = 5)None[source]

Move a list of S3 objects from source bucket to destination.

Parameters
  • source_bucket (str) – S3 bucket where the objects are stored.

  • source_keys (List[str]) – S3 keys where the objects are referenced.

  • destination_bucket (str) – S3 destination bucket.

  • destination_keys (List[str]) – S3 destination keys.

  • threads (int, optional) – Number of parallel uploads, by default 5.

Raises
  • IndexError – When the source_keys and destination_keys have different length.

  • ValueError – When the keys list is empty.

Examples

>>> move_keys(
...     source_bucket='bucket',
...     source_keys=[
...         'myFiles/song.mp3',
...         'myFiles/photo.jpg'
...     ],
...     destination_bucket='bucket',
...     destination_keys=[
...         'myMusic/song.mp3',
...         'myPhotos/photo.jpg'
...     ]
... )
s3_tools.move.move_object(source_bucket: str, source_key: str, destination_bucket: str, destination_key: str)None[source]

Move S3 object from source bucket and key to destination.

Parameters
  • source_bucket (str) – S3 bucket where the object is stored.

  • source_key (str) – S3 key where the object is referenced.

  • destination_bucket (str) – S3 destination bucket.

  • destination_key (str) – S3 destination key.

Examples

>>> move_object(
...    source_bucket='bucket',
...    source_key='myFiles/song.mp3',
...    destination_bucket='bucket',
...    destination_key='myMusic/song.mp3'
... )