S3 giving me NoSuchKey error even when the key exists

前端 未结 5 1132
野的像风
野的像风 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 02:10

    Another possible issue that I came across that was causing a line separator in my url for an object was that in one of AWS documentation for getting the key of an object shows this code as an example to get the key of an object.

    foreach ($results as $result) {
        foreach ($result['Contents'] as $object) {
            echo $object['Key'] . PHP_EOL;
        }
    }
    

    The problem is the PHP_EOL at the end. Just remove it and the line separator goes away.

    $object['Key'] . PHP_EOL; --> $object['Key'];

提交回复
热议问题