This is my boto3 command for getting the object with a specific key from an S3 bucket:
resp = s3client.get_object(Bucket='<>-<>', Key='MzA1MjY1NzkzX2QudHh0')
It gives the following error:
botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
I have checked in the bucket, and the key actually exists
Did I miss something or did I do something wrong here?
To prevent or mitigate future accidental deletions, consider the following features: Enable versioning to keep historical versions of an object. Enable Cross-Region Replication of objects. Enable MFA delete to require multi-factor authentication (MFA) when deleting an object version.
If an object already exists in a bucket, the new object will overwrite it because Amazon S3 stores the last write request.
A key prefix is a string of characters that can be the complete path in front of the object name (including the bucket name). For example, if an object (123. txt) is stored as BucketName/Project/WordFiles/123. txt, the prefix might be “BucketName/Project/WordFiles/123.
You have a %0A at the end of your URL; that's a line separator.
Since you know the key that you have is definitely in the name of the file you are looking for, I recommend using a filter
to get objects with names with your key as their prefix.
s3 = boto3.resource('s3') bucket = s3.Bucket('cypher-secondarybucket') for obj in bucket.objects.filter(Prefix='MzA1MjY1NzkzX2QudHh0'): print obj.key
When you run this code, you will get the key names of all the files that start with your key. This will help you find out what your file is exactly called on S3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With