terricain / aioboto3

Wrapper to use boto3 resources with the aiobotocore async backend
Apache License 2.0
743 stars 76 forks source link

Cannot download file using download_file() method #334

Closed PFernandezTorres closed 5 months ago

PFernandezTorres commented 5 months ago

I have tried downloading a file using the method described in the title but the behaviour is not the expected. The file downloads as it is supposed to, but when it finishes an exception is thrown saying: Screenshot 2024-04-30 at 11 03 04 AM.

This is current code:

class AWSS3Controller:

    def __init__(self):
        self.__session = aioboto3.Session()

    async def download(self, filename, supply_id, action):
        async with self.__session.client("s3", region_name=os.getenv("AWS_REGION_NAME")) as s3:
            if isinstance(filename, str):
                await s3.download_file(os.getenv("AWS_BUCKET_NAME"), f'{action}/{supply_id}/{filename}', filename)
            else:
                for name in filename:
                    await s3.download_file(os.getenv("AWS_BUCKET_NAME"), f'{action}/{supply_id}/{filename}', name)

As there is no more documentation, I don't know to keep going. Also I have tried declaring a client variable but another exception is thrown that the client is not awaited

PFernandezTorres commented 5 months ago

The env variable Wass not set...