I have a python script running in Windows that downloads files from an AWS S3 bucket to a Windows File Explorer folder. Before the download, I am trying to check if the file is already there. The section of My code is below. It is writing empty files after adding code to check if file exists. This code worked fine before I added the code to check if file exists (if not os.path.isfile(checkfileexists):).
download_filename = key['key'].split('/')[-1]
checkfileexists = os.path.join(download_dir, download_filename)
With open(download_path, 'wb') as file:
if not os.path.isfile(checkfileexists):
client.download_fileobj(
Bucket = bucket,
Key = key['key'],
Fileobj = file
)
Recognized by AWS
2