Updated docs for Container.
This commit is contained in:
@@ -18,9 +18,9 @@ namespace HPCloud\Storage\ObjectStorage;
|
|||||||
* Containers are iterable, which means you can iterate over a container
|
* Containers are iterable, which means you can iterate over a container
|
||||||
* and access each file inside of it.
|
* and access each file inside of it.
|
||||||
*
|
*
|
||||||
* Typically, containers are created using ObjectStorage::addContainer().
|
* Typically, containers are created using ObjectStorage::createContainer().
|
||||||
* They are retrieved using ObjectStorage::container() or
|
* They are retrieved using ObjectStorage::container() or
|
||||||
* ObjectStoarge::containers().
|
* ObjectStorage::containers().
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* <?php
|
* <?php
|
||||||
@@ -211,9 +211,30 @@ class Container implements \Countable, \IteratorAggregate {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Container.
|
* Construct a new Container.
|
||||||
|
*
|
||||||
|
* @attention
|
||||||
|
* Typically a container should be created by ObjectStorage::createContainer().
|
||||||
|
* Get existing containers with ObjectStorage::container() or
|
||||||
|
* ObjectStorage::containers(). Do not use this unless you know what you are doing.
|
||||||
|
*
|
||||||
|
* Simply creating a container does not save the container remotely.
|
||||||
|
*
|
||||||
|
* Also, this does no checking of the underlying container. That is, simply
|
||||||
|
* constructing a Container in no way guarantees that such a container exists
|
||||||
|
* on the origin object store.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* The name.
|
||||||
|
* @param string $url
|
||||||
|
* The full URL to the container.
|
||||||
|
* @param string $token
|
||||||
|
* The auth token.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct($name) {
|
public function __construct($name , $url = NULL, $token = NULL) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
$this->url = $url;
|
||||||
|
$this->token = $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,23 +329,23 @@ class Container implements \Countable, \IteratorAggregate {
|
|||||||
/**
|
/**
|
||||||
* Save an Object into Object Storage.
|
* Save an Object into Object Storage.
|
||||||
*
|
*
|
||||||
* This takes an \HPCloud\Storage\ObjectStorage\Object
|
* This takes an HPCloud::Storage::ObjectStorage::Object
|
||||||
* and stores it in the given container in the present
|
* and stores it in the given container in the present
|
||||||
* container on the remote object store.
|
* container on the remote object store.
|
||||||
*
|
*
|
||||||
* @param \HPCloud\Storage\ObjectStorage\Object $obj
|
* @param HPCloud::Storage::ObjectStorage::Object $obj
|
||||||
* The object to store.
|
* The object to store.
|
||||||
* @retval boolean
|
* @retval boolean
|
||||||
* TRUE if the object was saved.
|
* TRUE if the object was saved.
|
||||||
* @throws \HPCloud\Transport\LengthRequiredException
|
* @throws HPCloud::Transport::LengthRequiredException
|
||||||
* if the Content-Length could not be determined and chunked
|
* if the Content-Length could not be determined and chunked
|
||||||
* encoding was not enabled. This should not occur for this class,
|
* encoding was not enabled. This should not occur for this class,
|
||||||
* which always automatically generates Content-Length headers.
|
* which always automatically generates Content-Length headers.
|
||||||
* However, subclasses could generate this error.
|
* However, subclasses could generate this error.
|
||||||
* @throws \HPCloud\Transport\UnprocessableEntityException
|
* @throws HPCloud::Transport::UnprocessableEntityException
|
||||||
* if the checksome passed here does not match the checksum
|
* if the checksome passed here does not match the checksum
|
||||||
* calculated remotely.
|
* calculated remotely.
|
||||||
* @throws \HPCloud\Exception when an unexpected (usually
|
* @throws HPCloud::Exception when an unexpected (usually
|
||||||
* network-related) error condition arises.
|
* network-related) error condition arises.
|
||||||
*/
|
*/
|
||||||
public function save(Object $obj, $file = NULL) {
|
public function save(Object $obj, $file = NULL) {
|
||||||
@@ -429,13 +450,13 @@ class Container implements \Countable, \IteratorAggregate {
|
|||||||
* particularly in cases where custom headers have been set.
|
* particularly in cases where custom headers have been set.
|
||||||
* Use with caution.
|
* Use with caution.
|
||||||
*
|
*
|
||||||
* @param \HPCloud\Storage\ObjectStorage\Object $obj
|
* @param HPCloud::Storage::ObjectStorage::Object $obj
|
||||||
* The object to update.
|
* The object to update.
|
||||||
*
|
*
|
||||||
* @retval boolean
|
* @retval boolean
|
||||||
* TRUE if the metadata was updated.
|
* TRUE if the metadata was updated.
|
||||||
*
|
*
|
||||||
* @throws \HPCloud\Transport\FileNotFoundException
|
* @throws HPCloud::Transport::FileNotFoundException
|
||||||
* if the object does not already exist on the object storage.
|
* if the object does not already exist on the object storage.
|
||||||
*/
|
*/
|
||||||
public function updateMetadata(Object $obj) {
|
public function updateMetadata(Object $obj) {
|
||||||
@@ -477,7 +498,7 @@ class Container implements \Countable, \IteratorAggregate {
|
|||||||
* Note that there is no MOVE operation. You must copy and then DELETE
|
* Note that there is no MOVE operation. You must copy and then DELETE
|
||||||
* in order to achieve that.
|
* in order to achieve that.
|
||||||
*
|
*
|
||||||
* @param \HPCloud\Storage\ObjectStorage\Object $obj
|
* @param HPCloud::Storage::ObjectStorage::Object $obj
|
||||||
* The object to copy. This object MUST already be saved on the
|
* The object to copy. This object MUST already be saved on the
|
||||||
* remote server. The body of the object is not sent. Instead, the
|
* remote server. The body of the object is not sent. Instead, the
|
||||||
* copy operation is performed on the remote server. You can, and
|
* copy operation is performed on the remote server. You can, and
|
||||||
@@ -657,7 +678,7 @@ class Container implements \Countable, \IteratorAggregate {
|
|||||||
* that begin with that prefix.
|
* that begin with that prefix.
|
||||||
*
|
*
|
||||||
* (Directory-like behavior is also supported by using "directory
|
* (Directory-like behavior is also supported by using "directory
|
||||||
* markers". See objectsWithPath().)
|
* markers". See objectsByPath().)
|
||||||
*
|
*
|
||||||
* Prefixes
|
* Prefixes
|
||||||
*
|
*
|
||||||
@@ -716,7 +737,7 @@ class Container implements \Countable, \IteratorAggregate {
|
|||||||
* Specify a path (subdirectory) to traverse.
|
* Specify a path (subdirectory) to traverse.
|
||||||
*
|
*
|
||||||
* OpenStack Swift provides two basic ways to handle directory-like
|
* OpenStack Swift provides two basic ways to handle directory-like
|
||||||
* structures. The first is using a prefix (see objectsByPrefix()).
|
* structures. The first is using a prefix (see objectsWithPrefix()).
|
||||||
* The second is to create directory markers and use a path.
|
* The second is to create directory markers and use a path.
|
||||||
*
|
*
|
||||||
* A directory marker is just a file with a name that is
|
* A directory marker is just a file with a name that is
|
||||||
@@ -796,6 +817,12 @@ class Container implements \Countable, \IteratorAggregate {
|
|||||||
return $this->acl;
|
return $this->acl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get missing fields.
|
||||||
|
*
|
||||||
|
* Not all containers come fully instantiated. This method is sometimes
|
||||||
|
* called to "fill in" missing fields.
|
||||||
|
*/
|
||||||
protected function loadExtraData() {
|
protected function loadExtraData() {
|
||||||
// Do a GET on $url to fetch headers.
|
// Do a GET on $url to fetch headers.
|
||||||
$client = \HPCloud\Transport::instance();
|
$client = \HPCloud\Transport::instance();
|
||||||
|
|||||||
Reference in New Issue
Block a user