I am encountering an error while downloading a file from S3
programmatically. The code is give below.
The error is: An error occurred (404) when calling the HeadObject operation: Not Found
import csv
import json
import boto3
def get_file(bucket_name, file_name, filename):
try:
s3 = boto3.client('s3')
print("Inside get_file")
with open(filename, 'w') as data:
s3.download_file(bucket_name, file_name, filename)
except Exception as e:
print(str(e))
toName_cfg = 'seo_input_config.cfg'
bucket = 'my-landing-dev'
internal_folder = 'input'
directory_remote = 'Seo'
get_file(bucket, f'{internal_folder}/{directory_remote}/{toName_cfg}', f"{toName_cfg}")
The S3 directory structure is:
my-landing-dev/input/Seo/seo_input_config.cfg
I tried finding a solution by searching the net, but couldn't get any conclusive answer. Please help.
Thanks