I needed to get a header that isn't one of the built-in ones (ETag, Content-Length, Last-Modified, Content-Type) or metadata (ie. starting with 'X-Object-Meta-'), and there wasn't an easy way to do it.
(Specifically, I needed to get the 'X-Object-Manifest' header, because $object->delete() on a large object won't actually delete the segments that make it up, only the manifest! See #286)
I had do something like this:
class MyClass {
protected function apiHeadObject() {
$params = new Params();
return [
'method' => 'HEAD',
'path' => '{containerName}/{+name}',
'params' => [
'containerName' => $params->containerName(),
'name' => $params->objectName(),
],
];
}
public function getHeaders($container, $object_name) {
$object = $this->service
->getContainer($container)
->getObject($object_name);
/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $object->executeWithState($this->apiHeadObject());
return $response->getHeaders();
}
}
Given that there's lots of extensions to OpenStack which can be optionally enabled, including custom ones that a hosting provider may have created, it'd be nice to just have a way to arbitrarily get headers from an object.
Perhaps anything starting with 'X-' (other than metadata) could be captured in an additional array?
I needed to get a header that isn't one of the built-in ones (ETag, Content-Length, Last-Modified, Content-Type) or metadata (ie. starting with 'X-Object-Meta-'), and there wasn't an easy way to do it.
(Specifically, I needed to get the 'X-Object-Manifest' header, because
$object->delete()on a large object won't actually delete the segments that make it up, only the manifest! See #286)I had do something like this:
Given that there's lots of extensions to OpenStack which can be optionally enabled, including custom ones that a hosting provider may have created, it'd be nice to just have a way to arbitrarily get headers from an object.
Perhaps anything starting with 'X-' (other than metadata) could be captured in an additional array?