Nick Weavers
Nick Weavers

Reputation: 564

how to read results from aws s3 headObject using PHP SDK v2?

I am able to successfully get results back from a call to headObject like this. But then I can't access what's in $result as result is an object (Guzzle\Service|Resource\Model) and the data I see in it is obviously in protected variables meaning I have to use an object call to get it. But how do I know what the method call should be?

           $result = $client->headObject([
            'Bucket' => $bucket, // REQUIRED
            'Key' => $key // REQUIRED            
        ]);


        $relevantmetaData = array();
        $relevantmetaData['LastModified'] = $result->data['LastModified'];

The link here doesn't mention a method to get at $data

Upvotes: 1

Views: 2098

Answers (1)

Nick Weavers
Nick Weavers

Reputation: 564

I guess I should just have tried get(), it works.

$relevantmetaData['LastModified'] = $result->get('LastModified');

Upvotes: 2

Related Questions