protected function AmazonS3StreamWrapper::_amazons3_is_dir in AmazonS3 7
Determine whether the $uri is a directory.
Parameters
string $uri: A string containing the uri to the resource to check. If none is given defaults to $this->uri
Return value
bool TRUE if the resource is a directory
2 calls to AmazonS3StreamWrapper::_amazons3_is_dir()
- AmazonS3StreamWrapper::dir_opendir in ./
AmazonS3StreamWrapper.inc - Support for opendir().
- AmazonS3StreamWrapper::_amazons3_get_object in ./
AmazonS3StreamWrapper.inc - Try to fetch an object from the metadata cache.
File
- ./
AmazonS3StreamWrapper.inc, line 1189 - Drupal stream wrapper implementation for Amazon S3
Class
- AmazonS3StreamWrapper
- @file Drupal stream wrapper implementation for Amazon S3
Code
protected function _amazons3_is_dir($uri = NULL) {
if ($uri === NULL) {
$uri = $this->uri;
}
if ($uri !== NULL) {
$path = $this
->getLocalPath($uri);
if (strlen($path) === 0) {
return TRUE;
}
try {
$response = $this
->getS3()
->list_objects($this->bucket, array(
'prefix' => $path . '/',
'max-keys' => 1,
));
if ($response && isset($response->body->Contents->Key)) {
return TRUE;
}
} catch (Exception $e) {
watchdog('amazons3', 'Unable to check directory status of @path', array(
'@path' => $path,
), WATCHDOG_NOTICE);
}
}
return FALSE;
}