below code would download the file into the current dir. I want to make a folder in the current directory and download all the files to that dir.
for obj in bucket.objects.all():
s3.meta.client.download_file(
bucket.name, obj.key, obj.key)
CodePudding user response:
If you look at the download_file
method documentation for the S3 Bucket resource, you will find a reference to downloading a file to the /tmp/ directory. So with that in mind, you can change the 3rd parameter on your download_file
call to point to any directory you want.
s3.meta.client.download_file(
bucket.name, obj.key, f"/tmp/{obj.key}")