A guide exists for v2 of the AWS SDK for PHP to stream objects, like an image, from S3. In that guide, it references $command->getResponse()->getHeaders()
- both getResponse()
and getHeaders()
do not seem to exist in v3 of the SDK.
The documentation for the stream wrapper in v3 makes no reference to retrieving the headers. I've tried the native PHP get_headers()
with the s3://
path, but that returns false
(no errors). If I try get_headers($fullurl)
, I am able to retrieve the headers.
How can I retrieve the headers for the object using the streaming path s3://
for version 3 of the AWS SDK for PHP? Using the full URL will work for scenarios where I have private files.
Running some of the other native PHP functions that the documentation references do correctly return values using the s3://
path. There might be a SDK method call for the headers, I just can't find it.
$s3->registerStreamWrapper();
$headers = get_headers('s3://my-files/' . $filepath);
//$headers === false
$headers = get_headers('http://my-files.s3.amazonaws.com/' . $filepath);
//$headers correctly retrieves all the headers