-1

I am trying to execute the following program and facing this issue

botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found

import boto3
s3 = boto3.resource('s3')
copy_source = {
    'Bucket': 'forw',
    'Key': 'test'
}
s3.meta.client.copy(copy_source,Bucket='copybucket0526',Key='tet')
petezurich
  • 9,280
  • 9
  • 43
  • 57
sri
  • 83
  • 2
  • 3
  • 7

3 Answers3

2

Try this code it will work

import boto3
s3 = boto3.resource('s3')
copy_source = {
    'Bucket': 'source_bucket',
    'Key': 'dirname/subdirname/filename.gz'
}
s3.meta.client.copy(copy_source,Bucket='destination_bucket',Key='somedirname/new_or_same_filename.gz')

This is working I guess you are wrong in providing the path, means here you need to provide file complete path

0

In general a 404 code on HeadObject means that the resource does not exist.

0

in the place of key make sure the you are taking care of parent folder or sub directories(if any) of the file you are going to copy from the source bucket.

copy_source = {
    'Bucket': 'forw',
    'Key': 'top_directory/sub_directory/file.jpg'
}
Akhil S
  • 955
  • 11
  • 16