We're using the adapter to use an object store as our filesystem, but creating directories was not working. After investigating we got to the conclusion the createDir method only returns a array with the dirname.
Altough Rackspace doesn't officially supports the use of folders, there is a way of getting this to work. In order for directories to work you need to send two additional headers with the request.
Contents: None
Content-Type: application/directory
I've changed the createDir and normalizeObject to work with this solution.
public function createDir($dirname, Config $config)
{
// return ['path' => $dirname];
$headers = [];
if ($config->has('headers')) {
$headers = $config->get('headers');
}
if (!key_exists('Contents', $headers)) {
$headers['Contents'] = 'None';
}
if (!key_exists('Content-Type', $headers)) {
$headers['Content-Type'] = 'application/directory';
}
$config->set('headers', $headers);
return $this->write($dirname, '', $config);
}
protected function normalizeObject(DataObject $object)
{
$name = $object->getName();
$name = $this->removePathPrefix($name);
$mimetype = explode('; ', $object->getContentType());
return [
'type' => ((in_array('application/directory', $mimetype)) ? 'dir' : 'file'),
'dirname' => Util::dirname($name),
'path' => $name,
'timestamp' => strtotime($object->getLastModified()),
'mimetype' => reset($mimetype),
'size' => $object->getContentLength(),
];
}
Is this something you'll be willing to integrate in the adapter, if so do you need a pull request (never done that before :-)) or can you manually use the above code adjustments.