Class: CF_Object
Source Location: /cloudfiles.php
Class Details
Class Variables
Class Methods
constructor __construct [line 1902]
CF_Object __construct(
&$container, string
$name, [boolean
$force_exists = False], [
$dohead = True], obj
$container)
|
|
Class constructor
Parameters:
method compute_md5sum [line 2522]
string compute_md5sum(
&$data, filename|obj|string
$data)
|
|
Compute the MD5 checksum Calculate the MD5 checksum on either a PHP resource or data. The argument may either be a local filename, open resource for reading, or a string. WARNING: if you are uploading a big file over a stream it could get very slow to compute the md5 you probably want to set the $verify parameter to False in the write() method and compute yourself the md5 before if you have it.
Tags:
Parameters:
method getETag [line 2503]
Object's MD5 checksum Accessor method for reading Object's private ETag attribute.
Tags:
method load_from_filename [line 2393]
boolean load_from_filename(
string
$filename, [boolean
$verify = True])
|
|
Upload Object data from local filename This is a convenience function to upload the data from a local file. A True value for $verify will cause the method to compute the Object's MD5 checksum prior to uploading. Example: # ... authentication/connection/container code excluded
# ... see previous examples
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
# Upload my local README's content
#
Tags:
Parameters:
method public_ssl_uri [line 2052]
String representation of the Object's public SSL URI A string representing the Object's public SSL URI assuming that it's parent Container is CDN-enabled. Example: # ... authentication/connection/container code excluded
# ... see previous examples
# Print out the Object's CDN SSL URI (if it has one) in an HTML img-tag
#
print "<img src='$pic->public_ssl_uri()' />\n";
Tags:
method public_streaming_uri [line 2077]
string public_streaming_uri(
)
|
|
String representation of the Object's public Streaming URI A string representing the Object's public Streaming URI assuming that it's parent Container is CDN-enabled. Example: # ... authentication/connection/container code excluded
# ... see previous examples
# Print out the Object's CDN Streaming URI (if it has one) in an HTML img-tag
#
print "<img src='$pic->public_streaming_uri()' />\n";
Tags:
method public_uri [line 2026]
String representation of the Object's public URI A string representing the Object's public URI assuming that it's parent Container is CDN-enabled. Example: # ... authentication/connection/container code excluded
# ... see previous examples
# Print out the Object's CDN URI (if it has one) in an HTML img-tag
#
print "<img src='$pic->public_uri()' />\n";
Tags:
method purge_from_cdn [line 2466]
boolean purge_from_cdn(
[
$email = null])
|
|
Purge this Object from CDN Cache. Example:
Tags:
Parameters:
method read [line 2113]
string read(
[array
$hdrs = array()])
|
|
Read the remote Object's data Returns the Object's data. This is useful for smaller Objects such as images or office documents. Object's with larger content should use the stream() method below. Pass in $hdrs array to set specific custom HTTP headers such as If-Match, If-None-Match, If-Modified-Since, Range, etc. Example: # ... authentication/connection/container code excluded
# ... see previous examples
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
$data = $doc->read(); # read image content into a string variable
print $data;
# Or see stream() below for a different example.
#
Tags:
Parameters:
method save_to_filename [line 2438]
boolean save_to_filename(
string
$filename)
|
|
Save Object's data to local filename Given a local filename, the Object's data will be written to the newly created file. Example: # ... authentication/connection/container code excluded
# ... see previous examples
# Whoops! I deleted my local README, let me download/save it
#
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
Tags:
Parameters:
method set_etag [line 2490]
void set_etag(
string
$etag)
|
|
Set Object's MD5 checksum Manually set the Object's ETag. Including the ETag is mandatory for Cloud Files to perform end-to-end verification. Omitting the ETag forces the user to handle any data integrity checks.
Parameters:
method stream [line 2170]
string stream(
&$fp, [array
$hdrs = array()], resource
$fp)
|
|
Streaming read of Object's data Given an open PHP resource (see PHP's fopen() method), fetch the Object's data and write it to the open resource handle. This is useful for streaming an Object's content to the browser (videos, images) or for fetching content to a local file. Pass in $hdrs array to set specific custom HTTP headers such as If-Match, If-None-Match, If-Modified-Since, Range, etc. Example: # ... authentication/connection/container code excluded
# ... see previous examples
# Assuming this is a web script to display the README to the
# user's browser:
#
<?php
// grab README from storage system
//
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
// Hand it back to user's browser with appropriate content-type
//
$output = fopen("php://output", "w");
$doc->stream($output); # stream object content to PHP's output buffer
?>
# See read() above for a more simple example.
#
Tags:
Parameters:
method sync_manifest [line 2263]
Store new Object manifest Write's an Object's manifest to the remote Object. This will overwrite an prior Object manifest. Example: # ... authentication/connection/container code excluded
# ... see previous examples
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
# Define new manifest for the object
#
# Push the new manifest up to the storage system
#
Tags:
method sync_metadata [line 2221]
Store new Object metadata Write's an Object's metadata to the remote Object. This will overwrite an prior Object metadata. Example: # ... authentication/connection/container code excluded
# ... see previous examples
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
# Define new metadata for the object
#
"Author" => "EJ",
"Subject" => "How to use the PHP tests",
"Version" => "1.2.2"
);
# Define additional headers for the object
#
"Content-Disposition" => "attachment",
);
# Push the new metadata up to the storage system
#
Tags:
method write [line 2297]
boolean write(
[string|resource
$data = NULL], [float
$bytes = 0], [boolean
$verify = True])
|
|
Upload Object's data to Cloud Files Write data to the remote Object. The $data argument can either be a PHP resource open for reading (see PHP's fopen() method) or an in-memory variable. If passing in a PHP resource, you must also include the $bytes parameter. Example: # ... authentication/connection/container code excluded
# ... see previous examples
$my_docs = $conn->get_container("documents");
$doc = $my_docs->get_object("README");
# Upload placeholder text in my README
#
$doc->write("This is just placeholder text for now...");
Tags:
Parameters:
method _guess_content_type [line 1964]
boolean _guess_content_type(
string
$handle)
|
|
Internal check to get the proper mimetype. This function would go over the available PHP methods to get the MIME type. By default it will try to use the PHP fileinfo library which is available from PHP 5.3 or as an PECL extension (http://pecl.php.net/package/Fileinfo). It will get the magic file by default from the system wide file which is usually available in /usr/share/magic on Unix or try to use the file specified in the source directory of the API (share directory). if fileinfo is not available it will try to use the internal mime_content_type function.
Tags:
Parameters:
method __toString [line 1937]
String representation of Object Pretty print the Object's location and name
Tags:
|
|