S3 giving me NoSuchKey error even when the key exists

前端 未结 5 1017
野的像风
野的像风 2021-02-13 01:15

This is my boto3 command for getting the object with a specific key from an S3 bucket:

resp = s3client.get_object(Bucket=\'<>-<>\', Key=\'MzA1MjY1Nzkz         


        
5条回答
  •  既然无缘
    2021-02-13 01:59

    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.

提交回复
热议问题