DataObject
extends AbstractResource
in package
Objects are the basic storage entities in Cloud Files. They represent the files and their optional metadata you upload to the system. When you upload objects to Cloud Files, the data is stored as-is (without compression or encryption) and consists of a location (container), the object's name, and any metadata you assign consisting of key/value pairs.
Table of Contents
- GLOBAL_METADATA_PREFIX = 'X'
- METADATA_LABEL = 'Object'
- PATCH_CONTENT_TYPE = OpenCloudCommonConstantsMime::JSON_PATCH
- $aliases : array<string|int, mixed>
- The aliases configure for the properties of the instance.
- $content : EntityBody
- $contentLength : The
- $contentType : string
- $directory : bool
- $etag : string
- $lastModified : string
- $manifest : string
- $metadata : Metadata
- $metadataClass : string
- $name : The
- $service : ServiceInterface
- $container : Container
- $logger : LoggerInterface
- The logger instance
- $properties : array<string|int, mixed>
- Holds all the properties added by overloading.
- __call() : mixed
- Intercept non-existent method calls for dynamic getter/setter functionality.
- __construct() : mixed
- Also need to set Container parent and handle pseudo-directories.
- appendToMetadata() : array<string|int, mixed>
- Append a particular array of values to the existing metadata. Analogous to a merge. You must call to actually persist the metadata using the ObjectStore service.
- checkJsonError() : mixed
- Checks the most recent JSON operation for errors.
- copy() : Response
- createSymlinkFrom() : DataObject
- Create a symlink to this object from another named object. Requires the other object to either not exist or be empty.
- createSymlinkTo() : Response
- Create a symlink to another named object from this object. Requires this object to be empty.
- delete() : mixed
- fromResponse() : AbstractResource
- Factory method that allows for easy instantiation from a Response object.
- generateUuid() : mixed
- getCdnService() : Service
- For internal use only.
- getClient() : Client
- For internal use only.
- getContainer() : Container
- getContent() : EntityBody
- getContentLength() : mixed
- getContentType() : null|string
- getDirectory() : bool
- getEtag() : null|string
- getInstance() : static
- getLastModified() : mixed
- getLogger() : LoggerInterface
- Returns the Logger object.
- getManifest() : null|string
- getMetadata() : Metadata
- Returns metadata for this object.
- getName() : string
- getPublicUrl() : bool|Url
- getService() : Service
- For internal use only.
- getTemporaryUrl() : string
- Get a temporary URL for this object.
- getUrl() : mixed
- hasLogger() : bool
- isDirectory() : bool
- makeResourceIteratorOptions() : mixed
- populate() : mixed
- A collection list of DataObjects contains a different data structure than the one returned for the "Retrieve Object" operation. So we need to stock the values differently.
- populateFromResponse() : $this
- Takes a response and stocks common values from both the body and the headers.
- primaryKeyField() : mixed
- purge() : mixed
- Remove this object from the CDN.
- refresh() : mixed
- retrieveMetadata() : Metadata
- Retrieve metadata from the API. This method will then set and return this value.
- saveMetadata() : Response
- Push local metadata to the API, thereby executing a permanent save.
- setContainer() : $this
- setContent() : $this
- setContentLength() : $this
- setContentType() : $this
- setDirectory() : $this
- setEtag() : $this
- setLastModified() : mixed
- setLogger() : $this
- Sets the logger.
- setMetadata() : AbstractResource
- Set the metadata (local-only) for this object. You must call saveMetadata to actually persist the metadata using the ObjectStore service.
- setName() : $this
- stockHeaders() : array<string|int, mixed>
- Prepend/stock the header names with a resource-specific prefix.
- stripNamespace() : mixed
- toCamel() : mixed
- Convert a string to camelCase format.
- toUnderscores() : mixed
- Convert string to underscore format.
- trimHeaders() : array<string|int, mixed>
- Trim headers of their resource-specific prefixes.
- unsetMetadataItem() : Response
- To delete or unset a particular metadata item.
- update() : mixed
- url() : mixed
- getJsonHeader() : mixed
- getManifestHeader() : null|string
- getPatchHeaders() : mixed
- getProperty() : mixed
- Grab value out of the data array.
- headerIsValidMetadata() : mixed
- propertyExists() : bool
- Basic check to see whether property exists.
- setManifest() : $this
- setProperty() : mixed
- We can set a property under three conditions:
- stripPrefix() : mixed
- Strip an individual header name of its resource-specific prefix.
- checkAttributePrefix() : bool
- Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
- isAccessible() : bool
- Does the property exist in the object variable list (i.e. does it have public or protected visibility?)
Constants
GLOBAL_METADATA_PREFIX
public
mixed
GLOBAL_METADATA_PREFIX
= 'X'
METADATA_LABEL
public
mixed
METADATA_LABEL
= 'Object'
PATCH_CONTENT_TYPE
public
mixed
PATCH_CONTENT_TYPE
= OpenCloudCommonConstantsMime::JSON_PATCH
Properties
$aliases
The aliases configure for the properties of the instance.
protected
array<string|int, mixed>
$aliases
= array()
$content
protected
EntityBody
$content
$contentLength
protected
The
$contentLength
size of this object.
$contentType
protected
string
$contentType
The object's content type
$directory
protected
bool
$directory
= false
Whether or not this object is a "pseudo-directory"
Tags
$etag
protected
string
$etag
Etag.
$lastModified
protected
string
$lastModified
Date of last modification.
$manifest
protected
string
$manifest
= false
Manifest. Can be null so we use false to mean unset.
$metadata
protected
Metadata
$metadata
$metadataClass
protected
string
$metadataClass
= 'OpenCloud\Common\Metadata'
The FQCN of the metadata object used for the container.
$name
protected
The
$name
file name of the object
$service
protected
ServiceInterface
$service
The service object.
$container
private
Container
$container
$logger
The logger instance
private
LoggerInterface
$logger
$properties
Holds all the properties added by overloading.
private
array<string|int, mixed>
$properties
= array()
Methods
__call()
Intercept non-existent method calls for dynamic getter/setter functionality.
public
__call( $method, $args) : mixed
Parameters
Tags
Return values
mixed —__construct()
Also need to set Container parent and handle pseudo-directories.
public
__construct(Container $container[, null $data = null ]) : mixed
Parameters
- $container : Container
- $data : null = null
Return values
mixed —appendToMetadata()
Append a particular array of values to the existing metadata. Analogous to a merge. You must call to actually persist the metadata using the ObjectStore service.
public
appendToMetadata(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
-
The array of values you want to append to metadata.
Return values
array<string|int, mixed> —Metadata, after $values are appended.
checkJsonError()
Checks the most recent JSON operation for errors.
public
static checkJsonError() : mixed
Tags
Return values
mixed —copy()
public
copy(string $destination) : Response
Parameters
- $destination : string
-
Path (`container/object') of new object
Return values
Response —createSymlinkFrom()
Create a symlink to this object from another named object. Requires the other object to either not exist or be empty.
public
createSymlinkFrom(string $source) : DataObject
Parameters
- $source : string
-
Path (`container/object') of other object to symlink this object from
Tags
Return values
DataObject —The symlinked object
createSymlinkTo()
Create a symlink to another named object from this object. Requires this object to be empty.
public
createSymlinkTo(string $destination) : Response
Parameters
- $destination : string
-
Path (`container/object') of other object to symlink this object to
Tags
Return values
Response —The response
delete()
public
delete([mixed $params = array() ]) : mixed
Parameters
- $params : mixed = array()
Return values
mixed —fromResponse()
Factory method that allows for easy instantiation from a Response object.
public
static fromResponse(Response $response, ServiceInterface $service) : AbstractResource
For internal use only.
Parameters
- $response : Response
-
HTTP response from an API operation.
- $service : ServiceInterface
-
The ObjectStore service to associate with this ObjectStore resource object.
Return values
AbstractResource —A concrete sub-class of AbstractResource.
generateUuid()
public
static generateUuid() : mixed
Return values
mixed —getCdnService()
For internal use only.
public
getCdnService() : Service
Return values
Service —The CDN version of the ObjectStore service associated with this ObjectStore resource.
getClient()
For internal use only.
public
getClient() : Client
Return values
Client —The HTTP client associated with the associated ObjectStore service.
getContainer()
public
getContainer() : Container
Return values
Container —getContent()
public
getContent() : EntityBody
Return values
EntityBody —getContentLength()
public
getContentLength() : mixed
Return values
mixed —getContentType()
public
getContentType() : null|string
Return values
null|string —getDirectory()
public
getDirectory() : bool
Return values
bool —getEtag()
public
getEtag() : null|string
Return values
null|string —getInstance()
public
static getInstance() : static
Return values
static —getLastModified()
public
getLastModified() : mixed
Return values
mixed —getLogger()
Returns the Logger object.
public
getLogger() : LoggerInterface
Return values
LoggerInterface —getManifest()
public
getManifest() : null|string
Return values
null|string —Path (`container/object') from X-Object-Manifest header or null if the header does not exist
getMetadata()
Returns metadata for this object.
public
getMetadata() : Metadata
Return values
Metadata —Metadata set on this object.
getName()
public
getName() : string
Return values
string —getPublicUrl()
public
getPublicUrl([string $type = UrlType::CDN ]) : bool|Url
Parameters
- $type : string = UrlType::CDN
Return values
bool|Url —getService()
For internal use only.
public
getService() : Service
Return values
Service —The ObjectStore service associated with this ObjectStore resource.
getTemporaryUrl()
Get a temporary URL for this object.
public
getTemporaryUrl(int $expires, string $method[, bool $forcePublicUrl = false ]) : string
Parameters
- $expires : int
-
Expiration time in seconds
- $method : string
-
What method can use this URL? (
GET' orPUT') - $forcePublicUrl : bool = false
-
If set to TRUE, a public URL will always be used. The default is to use whatever URL type the user has set for the main service.
Tags
Return values
string —getUrl()
public
getUrl([mixed $path = null ][, array<string|int, mixed> $params = array() ]) : mixed
Parameters
- $path : mixed = null
- $params : array<string|int, mixed> = array()
Return values
mixed —hasLogger()
public
hasLogger() : bool
Return values
bool —isDirectory()
public
isDirectory() : bool
Return values
bool —Is this data object a pseudo-directory?
makeResourceIteratorOptions()
public
makeResourceIteratorOptions(mixed $resource) : mixed
Parameters
- $resource : mixed
Return values
mixed —populate()
A collection list of DataObjects contains a different data structure than the one returned for the "Retrieve Object" operation. So we need to stock the values differently.
public
populate(mixed $info[, mixed $setObjects = true ]) : mixed
Parameters
- $info : mixed
- $setObjects : mixed = true
Return values
mixed —populateFromResponse()
Takes a response and stocks common values from both the body and the headers.
public
populateFromResponse(Response $response) : $this
Parameters
- $response : Response
Return values
$this —primaryKeyField()
public
primaryKeyField() : mixed
Return values
mixed —purge()
Remove this object from the CDN.
public
purge([null $email = null ]) : mixed
Parameters
- $email : null = null
Return values
mixed —refresh()
public
refresh() : mixed
Return values
mixed —retrieveMetadata()
Retrieve metadata from the API. This method will then set and return this value.
public
retrieveMetadata() : Metadata
Return values
Metadata —Metadata returned from the ObjectStore service for this object/container.
saveMetadata()
Push local metadata to the API, thereby executing a permanent save.
public
saveMetadata(array<string|int, mixed> $metadata[, bool $stockPrefix = true ]) : Response
Parameters
- $metadata : array<string|int, mixed>
-
The array of values you want to set as metadata
- $stockPrefix : bool = true
-
Whether to prepend each array key with the metadata-specific prefix. For objects, this would be X-Object-Meta-Foo => Bar
Return values
Response —HTTP response from API operation.
setContainer()
public
setContainer(Container $container) : $this
Parameters
- $container : Container
Return values
$this —setContent()
public
setContent(mixed $content) : $this
Parameters
- $content : mixed
Return values
$this —setContentLength()
public
setContentLength( $contentLength) : $this
Parameters
Return values
$this —setContentType()
public
setContentType(string $contentType) : $this
Parameters
- $contentType : string
Return values
$this —setDirectory()
public
setDirectory( $directory) : $this
Parameters
Return values
$this —setEtag()
public
setEtag( $etag) : $this
Parameters
Return values
$this —setLastModified()
public
setLastModified(mixed $lastModified) : mixed
Parameters
- $lastModified : mixed
Return values
mixed —setLogger()
Sets the logger.
public
setLogger([LoggerInterface $logger = null ]) : $this
Parameters
- $logger : LoggerInterface = null
Return values
$this —setMetadata()
Set the metadata (local-only) for this object. You must call saveMetadata to actually persist the metadata using the ObjectStore service.
public
setMetadata(array<string|int, mixed> $data[, bool $constructFromResponse = false ]) : AbstractResource
Parameters
- $data : array<string|int, mixed>
-
Object/container metadata key/value pair array.
- $constructFromResponse : bool = false
-
Whether the metadata key/value pairs were obtiained from an HTTP response of an ObjectStore API operation.
Return values
AbstractResource —This object, with metadata set.
setName()
public
setName( $name) : $this
Parameters
Return values
$this —stockHeaders()
Prepend/stock the header names with a resource-specific prefix.
public
static stockHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
- $headers : array<string|int, mixed>
-
Headers to use on ObjectStore resource.
Return values
array<string|int, mixed> —Headers returned with appropriate prefix as expected by ObjectStore service.
stripNamespace()
public
stripNamespace(mixed $namespace) : mixed
Parameters
- $namespace : mixed
Return values
mixed —toCamel()
Convert a string to camelCase format.
public
toCamel( $string[, bool $capitalise = true ]) : mixed
Parameters
Return values
mixed —toUnderscores()
Convert string to underscore format.
public
toUnderscores( $string) : mixed
Parameters
Return values
mixed —trimHeaders()
Trim headers of their resource-specific prefixes.
public
static trimHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>
For internal use only.
Parameters
- $headers : array<string|int, mixed>
-
Headers as returned from an HTTP response
Return values
array<string|int, mixed> —Trimmed headers
unsetMetadataItem()
To delete or unset a particular metadata item.
public
unsetMetadataItem( $key) : Response
Parameters
Return values
Response —HTTP response returned from API operation to unset metadata item.
update()
public
update([mixed $params = array() ]) : mixed
Parameters
- $params : mixed = array()
Return values
mixed —url()
public
url([mixed $path = null ][, array<string|int, mixed> $query = array() ]) : mixed
Parameters
- $path : mixed = null
- $query : array<string|int, mixed> = array()
Tags
Return values
mixed —getJsonHeader()
protected
static getJsonHeader() : mixed
Return values
mixed —getManifestHeader()
protected
getManifestHeader() : null|string
Return values
null|string —getPatchHeaders()
protected
static getPatchHeaders() : mixed
Return values
mixed —getProperty()
Grab value out of the data array.
protected
getProperty(string $property) : mixed
Parameters
- $property : string
Return values
mixed —headerIsValidMetadata()
protected
static headerIsValidMetadata(mixed $header) : mixed
Parameters
- $header : mixed
Return values
mixed —propertyExists()
Basic check to see whether property exists.
protected
propertyExists(string $property[, bool $allowRetry = true ]) : bool
Parameters
- $property : string
-
The property name being investigated.
- $allowRetry : bool = true
-
If set to TRUE, the check will try to format the name in underscores because there are sometimes discrepancies between camelCaseNames and underscore_names.
Return values
bool —setManifest()
protected
setManifest(string $manifest) : $this
Parameters
- $manifest : string
-
Path (`container/object') to set as the value to X-Object-Manifest
Return values
$this —setProperty()
We can set a property under three conditions:
protected
setProperty(mixed $property, mixed $value) : mixed
- If it has a concrete setter: setProperty()
- If the property exists
- If the property name's prefix is in an approved list
Parameters
- $property : mixed
- $value : mixed
Return values
mixed —stripPrefix()
Strip an individual header name of its resource-specific prefix.
protected
static stripPrefix( $header) : mixed
Parameters
Return values
mixed —checkAttributePrefix()
Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
private
checkAttributePrefix(string $property) : bool
This is to support extension namespaces in some services.
Parameters
- $property : string
-
the name of the attribute
Return values
bool —isAccessible()
Does the property exist in the object variable list (i.e. does it have public or protected visibility?)
private
isAccessible( $property) : bool