Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
Added parameter $delimiter to the methods CF_Container::get_objects a…
Browse files Browse the repository at this point in the history
…nd CF_Http::get_objects. This parameter will enable the Container get_objects call to return files and "application/directory" objects in the base/root level.
  • Loading branch information
juanatgmo committed Mar 12, 2012
1 parent 32a79ac commit 4e8d15d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cloudfiles.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1471,11 +1471,11 @@ function list_objects($limit=0, $marker=NULL, $prefix=NULL, $path=NULL)
* @return array array of strings * @return array array of strings
* @throws InvalidResponseException unexpected response * @throws InvalidResponseException unexpected response
*/ */
function get_objects($limit=0, $marker=NULL, $prefix=NULL, $path=NULL) function get_objects($limit=0, $marker=NULL, $prefix=NULL, $path=NULL, $delimiter=NULL)
{ {
list($status, $reason, $obj_array) = list($status, $reason, $obj_array) =
$this->cfs_http->get_objects($this->name, $limit, $this->cfs_http->get_objects($this->name, $limit,
$marker, $prefix, $path); $marker, $prefix, $path, $delimiter);
#if ($status == 401 && $this->_re_auth()) { #if ($status == 401 && $this->_re_auth()) {
# return $this->get_objects($limit, $marker, $prefix, $path); # return $this->get_objects($limit, $marker, $prefix, $path);
#} #}
Expand All @@ -1485,12 +1485,14 @@ function get_objects($limit=0, $marker=NULL, $prefix=NULL, $path=NULL)
} }
$objects = array(); $objects = array();
foreach ($obj_array as $obj) { foreach ($obj_array as $obj) {
if(!isset($obj['subdir'])) {
$tmp = new CF_Object($this, $obj["name"], False, False); $tmp = new CF_Object($this, $obj["name"], False, False);
$tmp->content_type = $obj["content_type"]; $tmp->content_type = $obj["content_type"];
$tmp->content_length = (float) $obj["bytes"]; $tmp->content_length = (float) $obj["bytes"];
$tmp->set_etag($obj["hash"]); $tmp->set_etag($obj["hash"]);
$tmp->last_modified = $obj["last_modified"]; $tmp->last_modified = $obj["last_modified"];
$objects[] = $tmp; $objects[] = $tmp;
}
} }
return $objects; return $objects;
} }
Expand Down
5 changes: 4 additions & 1 deletion cloudfiles_http.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ function list_objects($cname,$limit=0,$marker=NULL,$prefix=NULL,$path=NULL)


# GET /v1/Account/Container?format=json # GET /v1/Account/Container?format=json
# #
function get_objects($cname,$limit=0,$marker=NULL,$prefix=NULL,$path=NULL) function get_objects($cname,$limit=0,$marker=NULL,$prefix=NULL,$path=NULL,$delimiter=NULL)
{ {
if (!$cname) { if (!$cname) {
$this->error_str = "Container name not set."; $this->error_str = "Container name not set.";
Expand All @@ -672,6 +672,9 @@ function get_objects($cname,$limit=0,$marker=NULL,$prefix=NULL,$path=NULL)
if ($path) { if ($path) {
$params[] = "path=".rawurlencode($path); $params[] = "path=".rawurlencode($path);
} }
if ($delimiter) {
$params[] = "delimiter=".rawurlencode($delimiter);
}
if (!empty($params)) { if (!empty($params)) {
$url_path .= "?" . implode("&", $params); $url_path .= "?" . implode("&", $params);
} }
Expand Down

0 comments on commit 4e8d15d

Please sign in to comment.