# Class Container

A container is a storage compartment for your data and provides a way for you to organize your data. You can think of a container as a folder in Windows or a directory in Unix. The primary difference between a container and these other file system concepts is that containers cannot be nested.

A container can also be CDN-enabled (for public access), in which case you will need to interact with a CDNContainer object instead of this one.

  OpenCloud\Common\Base
  OpenCloud\ObjectStore\Resource\AbstractResource
  OpenCloud\ObjectStore\Resource\AbstractContainer
  OpenCloud\ObjectStore\Resource\Container

Namespace: OpenCloud\ObjectStore\Resource
Located at OpenCloud/ObjectStore/Resource/Container.php

Methods summary
`public` | # `__construct( `OpenCloud\Common\Service\ServiceInterface` $service, mixed $data = null )` #### Overrides `OpenCloud\ObjectStore\Resource\AbstractContainer::__construct()`
`public static static` | # `fromResponse( Guzzle\Http\Message\Response $response, `OpenCloud\Common\Service\ServiceInterface` $service )` Factory method that instantiates an object from a Response object. Factory method that instantiates an object from a Response object. #### Parameters $response `Guzzle\Http\Message\Response` $response $service ``OpenCloud\Common\Service\ServiceInterface`` $service #### Returns `static` #### Overrides `OpenCloud\ObjectStore\Resource\AbstractResource::fromResponse()`
`public null|`OpenCloud\ObjectStore\Resource\CDNContainer`` | # `getCdn( )` Get the CDN object. Get the CDN object. #### Returns `null|`OpenCloud\ObjectStore\Resource\CDNContainer`` #### Throws ``OpenCloud\Common\Exceptions\CdnNotAvailableError``
`public null|string|integer` | # `getObjectCount( )` It would be awesome to put these convenience methods (which are identical to the ones in the Account object) in a trait, but we have to wait for v5.3 EOL first... It would be awesome to put these convenience methods (which are identical to the ones in the Account object) in a trait, but we have to wait for v5.3 EOL first... #### Returns `null|string|integer`
`public null|string|integer` | # `getBytesUsed( )` #### Returns `null|string|integer`
`public mixed` | # `setCountQuota( mixed $value )` #### Parameters $value `mixed` $value #### Returns `mixed`
`public null|string|integer` | # `getCountQuota( )` #### Returns `null|string|integer`
`public mixed` | # `setBytesQuota( mixed $value )` #### Parameters $value `mixed` $value #### Returns `mixed`
`public null|string|integer` | # `getBytesQuota( )` #### Returns `null|string|integer`
`public` | # `delete( mixed $deleteObjects = false )`
`public mixed` | # `deleteAllObjects( )` Deletes all objects that this container currently contains. Useful when doing operations (like a delete) that require an empty container first. Deletes all objects that this container currently contains. Useful when doing operations (like a delete) that require an empty container first. #### Returns `mixed`
`public 'OpenCloud\Common\Collection` | # `objectList( array $params = array() )` Creates a Collection of objects in the container Creates a Collection of objects in the container #### Parameters $params `array` $params associative array of parameter values. * account/tenant - The unique identifier of the account/tenant. * container- The unique identifier of the container. * limit (Optional) - The number limit of results. * marker (Optional) - Value of the marker, that the object names greater in value than are returned. * end_marker (Optional) - Value of the marker, that the object names less in value than are returned. * prefix (Optional) - Value of the prefix, which the returned object names begin with. * format (Optional) - Value of the serialized response format, either json or xml. * delimiter (Optional) - Value of the delimiter, that all the object names nested in the container are returned. #### Returns `'OpenCloud\Common\Collection` #### Throws `ObjFetchError` #### Link for a list of possible parameter names and values
`public Guzzle\Http\Message\Response` | # `enableLogging( )` Turn on access logs, which track all the web traffic that your data objects accrue. Turn on access logs, which track all the web traffic that your data objects accrue. #### Returns `Guzzle\Http\Message\Response`
`public Guzzle\Http\Message\Response` | # `disableLogging( )` Disable access logs. Disable access logs. #### Returns `Guzzle\Http\Message\Response`
`public` | # `enableCdn( null $ttl = null )` Enable this container for public CDN access. Enable this container for public CDN access. #### Parameters $ttl `null` $ttl
`public Guzzle\Http\Message\Response` | # `disableCdn( )` Disables the containers CDN function. Note that the container will still be available on the CDN until its TTL expires. Disables the containers CDN function. Note that the container will still be available on the CDN until its TTL expires. #### Returns `Guzzle\Http\Message\Response`
`public` | # `refresh( mixed $id = null, mixed $url = null )`
`public `OpenCloud\ObjectStore\Resource\DataObject`` | # `dataObject( mixed $info = null )` Get either a fresh data object (no $info), or get an existing one by passing in data for population. Get either a fresh data object (no $info), or get an existing one by passing in data for population. #### Parameters $info `mixed` $info #### Returns ``OpenCloud\ObjectStore\Resource\DataObject``
`public `OpenCloud\ObjectStore\Resource\DataObject`` | # `getObject( string $name, array $headers = array() )` Retrieve an object from the API. Apart from using the name as an identifier, you can also specify additional headers that will be used fpr a conditional GET request. These are Retrieve an object from the API. Apart from using the name as an identifier, you can also specify additional headers that will be used fpr a conditional GET request. These are `If-Match' `If-None-Match' `If-Modified-Since' `If-Unmodified-Since' `Range' For example: bytes=-5 would mean the last 5 bytes of the object bytes=10-15 would mean 5 bytes after a 10 byte offset bytes=32- would mean all dat after first 32 bytes These are also documented in RFC 2616. #### Parameters $name `string` $name $headers `array` $headers #### Returns ``OpenCloud\ObjectStore\Resource\DataObject``
`public mixed` | # `getPartialObject( mixed $name, array $headers = array() )` Essentially the same as `OpenCloud\ObjectStore\Resource\Container::getObject()`, except only the metadata is fetched from the API. This is useful for cases when the user does not want to fetch the full entity body of the object, only its metadata. Essentially the same as `OpenCloud\ObjectStore\Resource\Container::getObject()`, except only the metadata is fetched from the API. This is useful for cases when the user does not want to fetch the full entity body of the object, only its metadata. #### Parameters $name `mixed` $name $headers `array` $headers #### Returns `mixed` $this
`public boolean` | # `objectExists( mixed $name )` Check if an object exists inside a container. Uses `OpenCloud\ObjectStore\Resource\Container::getPartialObject()` to save on bandwidth and time. Check if an object exists inside a container. Uses `OpenCloud\ObjectStore\Resource\Container::getPartialObject()` to save on bandwidth and time. #### Parameters $name `mixed` $name Object name #### Returns `boolean` True, if object exists in this container; false otherwise.
`public `OpenCloud\ObjectStore\Resource\DataObject`` | # `uploadObject( mixed $name, mixed $data, array $headers = array() )` Upload a single file to the API. Upload a single file to the API. #### Parameters $name `mixed` $name Name that the file will be saved as in your container. $data `mixed` $data Either a string or stream representation of the file contents to be uploaded. $headers `array` $headers Optional headers that will be sent with the request (useful for object metadata). #### Returns ``OpenCloud\ObjectStore\Resource\DataObject``
`public Guzzle\Http\Message\Response` | # `uploadObjects( array $files, array $commonHeaders = array() )` Upload an array of objects for upload. This method optimizes the upload procedure by batching requests for faster execution. This is a very useful procedure when you just have a bunch of unremarkable files to be uploaded quickly. Each file must be under 5GB. Upload an array of objects for upload. This method optimizes the upload procedure by batching requests for faster execution. This is a very useful procedure when you just have a bunch of unremarkable files to be uploaded quickly. Each file must be under 5GB. #### Parameters $files `array` $files With the following array structure: `name' Name that the file will be saved as in your container. Required. `path' Path to an existing file, OR `body' Either a string or stream representation of the file contents to be uploaded. $commonHeaders `array` $headers Optional headers that will be sent with the request (useful for object metadata). #### Returns `Guzzle\Http\Message\Response` #### Throws ``OpenCloud\Common\Exceptions\InvalidArgumentError``
`public mixed` | # `setupObjectTransfer( array $options = array() )` When uploading large files (+5GB), you need to upload the file as chunks using multibyte transfer. This method sets up the transfer, and in order to execute the transfer, you need to call upload() on the returned object. When uploading large files (+5GB), you need to upload the file as chunks using multibyte transfer. This method sets up the transfer, and in order to execute the transfer, you need to call upload() on the returned object. #### Parameters $options `array` Options #### Returns `mixed` #### Throws ``OpenCloud\Common\Exceptions\InvalidArgumentError`` #### See \OpenCloud\ObjectStore\Upload\UploadBuilder::setOptions for a list of accepted options.
`public` | # `uploadDirectory( mixed $path )` Upload the contents of a local directory to a remote container, effectively syncing them. Upload the contents of a local directory to a remote container, effectively syncing them. #### Parameters $path `mixed` $path The local path to the directory.
`public` | # `isCdnEnabled( )`

Methods inherited from OpenCloud\ObjectStore\Resource\AbstractContainer
`createRefreshRequest(), getTransId(), getUrl(), hasLogRetention(), primaryKeyField(), setStaticErrorPage(), setStaticIndexPage()`

Methods inherited from OpenCloud\ObjectStore\Resource\AbstractResource
`appendToMetadata(), getCdnService(), getClient(), getMetadata(), getService(), headerIsValidMetadata(), retrieveMetadata(), saveMetadata(), setMetadata(), stockHeaders(), stripPrefix(), trimHeaders(), unsetMetadataItem()`

Methods inherited from OpenCloud\Common\Base
`__call(), checkJsonError(), generateUuid(), getInstance(), getJsonHeader(), getLogger(), getProperty(), makeResourceIteratorOptions(), populate(), propertyExists(), setLogger(), setProperty(), stripNamespace(), toCamel(), toUnderscores()`

Constants summary
`string` | `METADATA_LABEL` | `'Container'` | #

Constants inherited from OpenCloud\ObjectStore\Resource\AbstractResource
`GLOBAL_METADATA_PREFIX`

Properties inherited from OpenCloud\ObjectStore\Resource\AbstractContainer
`$metadataClass, $name`

Properties inherited from OpenCloud\ObjectStore\Resource\AbstractResource
`$metadata, $service`

Properties inherited from OpenCloud\Common\Base
`$aliases`