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.
Methods summary
public
|
#
__construct( OpenCloud\ObjectStore\Resource\Container $container, mixed $cdata = null )
A DataObject is related to a container and has a name
A DataObject is related to a container and has a name
If $name is specified, then it attempts to retrieve the object
from the object store.
Parameters
- $container
OpenCloud\ObjectStore\Resource\Container
$container the container holding this object
- $cdata
mixed $cdata if an object or array, it is treated as values with which to populate the
object. If it is a string, it is treated as a name and the object's info is
retrieved from the service.
Overrides
|
public
boolean
|
#
isDirectory( )
Is this data object a pseudo-directory?
Is this data object a pseudo-directory?
Returns
boolean
|
public
string
|
#
primaryKeyField( )
Allow other objects to know what the primary key is.
Allow other objects to know what the primary key is.
Returns
string
|
public
|
#
setContentType( string $contentType )
Set this file's content type.
Set this file's content type.
Parameters
- $contentType
string $contentType
|
public
string
|
|
public
string
|
#
url( string $subresource = '' )
Returns the URL of the data object
Returns the URL of the data object
If the object is new and doesn't have a name, then an exception is
thrown.
Parameters
- $subresource
string $subresource Not used
Returns
string
Throws
NoNameError
Overrides
|
public
boolean
|
#
create( array $params = array(), string $filename = null, mixed $extractArchive = null )
Creates (or updates; both the same) an instance of the object
Creates (or updates; both the same) an instance of the object
Parameters
- $params
array $params an optional associative array that can contain the 'name' and
'content_type' of the object
- $filename
string $filename if provided, then the object is loaded from the specified file
- $extractArchive
Returns
boolean
Throws
CreateUpdateError
Api
|
public
boolean
|
#
update( array $params = array(), string $filename = '' )
Update() is provided as an alias for the Create() method
Update() is provided as an alias for the Create() method
Since update and create both use a PUT request, the different functions may
allow the developer to distinguish between the semantics in his or her
application.
Parameters
- $params
array $params an optional associative array that can contain the 'name' and 'type' of
the object
- $filename
string $filename if provided, the object is loaded from the file
Returns
boolean
Api
|
public
boolean
|
#
updateMetadata( array $params = array() )
UpdateMetadata() - updates headers
UpdateMetadata() - updates headers
Updates metadata headers
Parameters
- $params
array $params an optional associative array that can contain the 'name' and 'type' of
the object
Returns
boolean
Api
|
public
HttpResponse
|
#
delete( array $params = array() )
Deletes an object from the Object Store
Deletes an object from the Object Store
Note that we can delete without retrieving by specifying the name in the
parameter array.
Parameters
- $params
array $params an array of parameters
Returns
HttpResponse if successful; FALSE if not
Throws
DeleteError
Api
|
public
|
#
copy( OpenCloud\ObjectStore\Resource\DataObject $target )
Copies the object to another container/object
Copies the object to another container/object
Note that this function, because it operates within the Object Store itself,
is much faster than downloading the object and re-uploading it to a new
object.
Parameters
|
public
OpenCloud\ObjectStore\Resource\Container
|
#
container( )
Returns the container of the object
Returns the container of the object
Returns
|
public
string
|
#
tempUrl( string $secret, integer $expires, string $method )
returns the TEMP_URL for the object
returns the TEMP_URL for the object
Some notes:
- The
$secret value is arbitrary; it must match the value set for
the X-Account-Meta-Temp-URL-Key on the account level. This can be
set by calling $service->SetTempUrlSecret($secret) .
- The
$expires value is the number of seconds you want the
temporary URL to be valid for. For example, use 60 to make it valid
for a minute
- The
$method must be either GET or PUT. No other methods are
supported.
Parameters
- $secret
string $secret the shared secret
- $expires
integer $expires the expiration time (in seconds)
- $method
string $method either GET or PUT
Returns
string the temporary URL
|
public
|
#
setData( string $data )
Sets object data from string
Sets object data from string
This is a convenience function to permit the use of other technologies for
setting an object's content.
Parameters
|
public
string
|
#
saveToString( )
Return object's data as a string
Return object's data as a string
Returns
string the entire object
|
public
boolean
|
#
saveToFilename( string $filename )
Saves the object's data to local filename
Saves the object's data to local filename
Given a local filename, the Object's data will be written to the newly
created file.
Example:
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
$doc->SaveToFilename("/home/ej/cloudfiles/readme.restored");
Parameters
- $filename
string $filename name of local file to write data to
Returns
boolean TRUE if successful
Throws
IOException error opening file
InvalidResponseException unexpected response
|
public
boolean
|
#
saveToStream( string $resource )
Saves the object's to a stream filename
Saves the object's to a stream filename
Given a local filename, the Object's data will be written to the stream
Example:
$my_docs = $conn->get_container("documents");
$doc = $my_docs->DataObject(array("name"=>"README"));
$fp = fopen('php://temp', 'r+');
$doc->SaveToStream($fp);
fclose($fp);
Parameters
- $resource
string $filename name of local file to write data to
Returns
boolean TRUE if successful
Throws
IOException error opening file
InvalidResponseException unexpected response
|
public
string
|
#
getETag( )
Returns the object's MD5 checksum
Returns the object's MD5 checksum
Accessor method for reading Object's private ETag attribute.
Returns
string MD5 checksum hexidecimal string
Api
|
public
|
#
purgeCDN( string $email )
Purges the object from the CDN
Purges the object from the CDN
Note that the object will still be served up to the time of its TTL
value.
Parameters
- $email
string $email An email address that will be notified when the object is purged.
Throws
CdnError if the container is not CDN-enabled
CdnHttpError if there is an HTTP error in the transaction
Api
|
public
string
|
#
CDNURL( )
Returns the CDN URL (for managing the object)
Returns the CDN URL (for managing the object)
Note that the DataObject::PublicURL() method is used to return the
publicly-available URL of the object, while the CDNURL() is used to manage the
object.
Returns
string
|
public
string
|
#
publicURL( string $type = null )
Returns the object's Public CDN URL, if available
Returns the object's Public CDN URL, if available
Parameters
- $type
string $type can be 'streaming', 'ssl', 'ios-streaming', or anything else for the
default URL. For example, $object->PublicURL('ios-streaming')
Returns
string
Api
|
public
|
|
Properties summary
public
string
|
$name
|
|
#
Object name. The only restriction on object names is that they must be less
than 1024 bytes in length after URL encoding.
Object name. The only restriction on object names is that they must be less
than 1024 bytes in length after URL encoding.
|
public
string
|
$hash
|
|
#
Hash value of the object.
Hash value of the object.
|
public
string
|
$bytes
|
|
|
public
string
|
$last_modified
|
|
#
Date of last modification.
Date of last modification.
|
public
string
|
$content_type
|
|
|
public
string
|
$content_length
|
|
|
public
boolean
|
$send_etag
|
true |
#
Whether or not to calculate and send an ETag on create.
Whether or not to calculate and send an ETag on create.
|
public
boolean
|
$clearStatusCache
|
false |
#
Option for clearing the status cache when objects are uploaded to API. By
default, it is set to FALSE for performance; but if you have files that are
rapidly and very often updated, you might want to clear the status cache so PHP
reads the files directly, instead of relying on the cache.
Option for clearing the status cache when objects are uploaded to API. By
default, it is set to FALSE for performance; but if you have files that are
rapidly and very often updated, you might want to clear the status cache so PHP
reads the files directly, instead of relying on the cache.
Link
|