Вот соответствующая часть кода. В частности, она висит в строке await s3_client.copy:
Код: Выделить всё
async def _copy_image(
s3_client, source_key: str, destination_key: str, bucket_name: str
) -> None:
copy_source = {
"Bucket": bucket_name,
"Key": source_key,
}
await s3_client.copy(
CopySource=copy_source,
Bucket=bucket_name,
Key=destination_key,
)
async def copy_images_for_new_guide(
keys: list[str],
new_guide_id: int,
org_id: int,
) -> None:
session = aioboto3.Session()
async with session.client(
"s3",
region_name=variables.secrets.AWS_REGION_NAME,
) as s3_client:
tasks = []
for key in keys:
new_key = (
f"orgs/org_{org_id}/guide_{new_guide_id}/{key.split('/')[-1]}"
)
tasks.append(
_copy_image(
s3_client, key, new_key, variables.settings.IMAGES_BUCKET
)
)
await asyncio.gather(*tasks)
Подробнее здесь: https://stackoverflow.com/questions/786 ... iles-in-s3