Skip to content

Fetching the statusCode of request for method calls on S3 Client #2123

@qwertynik

Description

@qwertynik

Confirm by changing [ ] to [x] below:

Version of AWS SDK for PHP?: 3.154.6

Version of PHP (php -v)?: 7.4.6

Describe the question

        $downloadResult = $s3Client->getObject([
          'Bucket' => 'bucket',
          'Key' => 'key',
          'SaveAs' => "$folderPath/$feedFileName"
        ]);

The above code snippet returns and instance of \Aws\Result. However, there are no methods on this instance of fetch the status code. get and search does not work.

        var_dump($downloadResult->search('statusCode'));
        var_dump($downloadResult->get('statusCode'));
        var_dump($downloadResult->search('metadata.statusCode'));
        var_dump($downloadResult->get('metadata.statusCode'));

Is there a way to get the statusCode? The last resort is to use Reflection. Seems like overkill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    guidanceQuestion that needs advice or information.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions