Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../includes/cloudfil...
File: cloudfiles.php
if (!$this->content_type && (string)is_file($handle) && function_exists("mime_content_type")) {
[2000] Fix | Delete
$this->content_type = @mime_content_type($handle);
[2001] Fix | Delete
}
[2002] Fix | Delete
[2003] Fix | Delete
if (!$this->content_type) {
[2004] Fix | Delete
throw new BadContentTypeException("Required Content-Type not set");
[2005] Fix | Delete
}
[2006] Fix | Delete
return True;
[2007] Fix | Delete
}
[2008] Fix | Delete
[2009] Fix | Delete
/**
[2010] Fix | Delete
* String representation of the Object's public URI
[2011] Fix | Delete
*
[2012] Fix | Delete
* A string representing the Object's public URI assuming that it's
[2013] Fix | Delete
* parent Container is CDN-enabled.
[2014] Fix | Delete
*
[2015] Fix | Delete
* Example:
[2016] Fix | Delete
* <code>
[2017] Fix | Delete
* # ... authentication/connection/container code excluded
[2018] Fix | Delete
* # ... see previous examples
[2019] Fix | Delete
*
[2020] Fix | Delete
* # Print out the Object's CDN URI (if it has one) in an HTML img-tag
[2021] Fix | Delete
* #
[2022] Fix | Delete
* print "<img src='$pic->public_uri()' />\n";
[2023] Fix | Delete
* </code>
[2024] Fix | Delete
*
[2025] Fix | Delete
* @return string Object's public URI or NULL
[2026] Fix | Delete
*/
[2027] Fix | Delete
function public_uri()
[2028] Fix | Delete
{
[2029] Fix | Delete
if ($this->container->cdn_enabled) {
[2030] Fix | Delete
return $this->container->cdn_uri . "/" . $this->name;
[2031] Fix | Delete
}
[2032] Fix | Delete
return NULL;
[2033] Fix | Delete
}
[2034] Fix | Delete
[2035] Fix | Delete
/**
[2036] Fix | Delete
* String representation of the Object's public SSL URI
[2037] Fix | Delete
*
[2038] Fix | Delete
* A string representing the Object's public SSL URI assuming that it's
[2039] Fix | Delete
* parent Container is CDN-enabled.
[2040] Fix | Delete
*
[2041] Fix | Delete
* Example:
[2042] Fix | Delete
* <code>
[2043] Fix | Delete
* # ... authentication/connection/container code excluded
[2044] Fix | Delete
* # ... see previous examples
[2045] Fix | Delete
*
[2046] Fix | Delete
* # Print out the Object's CDN SSL URI (if it has one) in an HTML img-tag
[2047] Fix | Delete
* #
[2048] Fix | Delete
* print "<img src='$pic->public_ssl_uri()' />\n";
[2049] Fix | Delete
* </code>
[2050] Fix | Delete
*
[2051] Fix | Delete
* @return string Object's public SSL URI or NULL
[2052] Fix | Delete
*/
[2053] Fix | Delete
function public_ssl_uri()
[2054] Fix | Delete
{
[2055] Fix | Delete
if ($this->container->cdn_enabled) {
[2056] Fix | Delete
return $this->container->cdn_ssl_uri . "/" . $this->name;
[2057] Fix | Delete
}
[2058] Fix | Delete
return NULL;
[2059] Fix | Delete
}
[2060] Fix | Delete
/**
[2061] Fix | Delete
* String representation of the Object's public Streaming URI
[2062] Fix | Delete
*
[2063] Fix | Delete
* A string representing the Object's public Streaming URI assuming that it's
[2064] Fix | Delete
* parent Container is CDN-enabled.
[2065] Fix | Delete
*
[2066] Fix | Delete
* Example:
[2067] Fix | Delete
* <code>
[2068] Fix | Delete
* # ... authentication/connection/container code excluded
[2069] Fix | Delete
* # ... see previous examples
[2070] Fix | Delete
*
[2071] Fix | Delete
* # Print out the Object's CDN Streaming URI (if it has one) in an HTML img-tag
[2072] Fix | Delete
* #
[2073] Fix | Delete
* print "<img src='$pic->public_streaming_uri()' />\n";
[2074] Fix | Delete
* </code>
[2075] Fix | Delete
*
[2076] Fix | Delete
* @return string Object's public Streaming URI or NULL
[2077] Fix | Delete
*/
[2078] Fix | Delete
function public_streaming_uri()
[2079] Fix | Delete
{
[2080] Fix | Delete
if ($this->container->cdn_enabled) {
[2081] Fix | Delete
return $this->container->cdn_streaming_uri . "/" . $this->name;
[2082] Fix | Delete
}
[2083] Fix | Delete
return NULL;
[2084] Fix | Delete
}
[2085] Fix | Delete
[2086] Fix | Delete
/**
[2087] Fix | Delete
* Read the remote Object's data
[2088] Fix | Delete
*
[2089] Fix | Delete
* Returns the Object's data. This is useful for smaller Objects such
[2090] Fix | Delete
* as images or office documents. Object's with larger content should use
[2091] Fix | Delete
* the stream() method below.
[2092] Fix | Delete
*
[2093] Fix | Delete
* Pass in $hdrs array to set specific custom HTTP headers such as
[2094] Fix | Delete
* If-Match, If-None-Match, If-Modified-Since, Range, etc.
[2095] Fix | Delete
*
[2096] Fix | Delete
* Example:
[2097] Fix | Delete
* <code>
[2098] Fix | Delete
* # ... authentication/connection/container code excluded
[2099] Fix | Delete
* # ... see previous examples
[2100] Fix | Delete
*
[2101] Fix | Delete
* $my_docs = $conn->get_container("documents");
[2102] Fix | Delete
* $doc = $my_docs->get_object("README");
[2103] Fix | Delete
* $data = $doc->read(); # read image content into a string variable
[2104] Fix | Delete
* print $data;
[2105] Fix | Delete
*
[2106] Fix | Delete
* # Or see stream() below for a different example.
[2107] Fix | Delete
* #
[2108] Fix | Delete
* </code>
[2109] Fix | Delete
*
[2110] Fix | Delete
* @param array $hdrs user-defined headers (Range, If-Match, etc.)
[2111] Fix | Delete
* @return string Object's data
[2112] Fix | Delete
* @throws InvalidResponseException unexpected response
[2113] Fix | Delete
*/
[2114] Fix | Delete
function read($hdrs=array())
[2115] Fix | Delete
{
[2116] Fix | Delete
list($status, $reason, $data) =
[2117] Fix | Delete
$this->container->cfs_http->get_object_to_string($this, $hdrs);
[2118] Fix | Delete
#if ($status == 401 && $this->_re_auth()) {
[2119] Fix | Delete
# return $this->read($hdrs);
[2120] Fix | Delete
#}
[2121] Fix | Delete
if (($status < 200) || ($status > 299
[2122] Fix | Delete
&& $status != 412 && $status != 304)) {
[2123] Fix | Delete
throw new InvalidResponseException("Invalid response (".$status."): "
[2124] Fix | Delete
. $this->container->cfs_http->get_error());
[2125] Fix | Delete
}
[2126] Fix | Delete
return $data;
[2127] Fix | Delete
}
[2128] Fix | Delete
[2129] Fix | Delete
/**
[2130] Fix | Delete
* Streaming read of Object's data
[2131] Fix | Delete
*
[2132] Fix | Delete
* Given an open PHP resource (see PHP's fopen() method), fetch the Object's
[2133] Fix | Delete
* data and write it to the open resource handle. This is useful for
[2134] Fix | Delete
* streaming an Object's content to the browser (videos, images) or for
[2135] Fix | Delete
* fetching content to a local file.
[2136] Fix | Delete
*
[2137] Fix | Delete
* Pass in $hdrs array to set specific custom HTTP headers such as
[2138] Fix | Delete
* If-Match, If-None-Match, If-Modified-Since, Range, etc.
[2139] Fix | Delete
*
[2140] Fix | Delete
* Example:
[2141] Fix | Delete
* <code>
[2142] Fix | Delete
* # ... authentication/connection/container code excluded
[2143] Fix | Delete
* # ... see previous examples
[2144] Fix | Delete
*
[2145] Fix | Delete
* # Assuming this is a web script to display the README to the
[2146] Fix | Delete
* # user's browser:
[2147] Fix | Delete
* #
[2148] Fix | Delete
* <?php
[2149] Fix | Delete
* // grab README from storage system
[2150] Fix | Delete
* //
[2151] Fix | Delete
* $my_docs = $conn->get_container("documents");
[2152] Fix | Delete
* $doc = $my_docs->get_object("README");
[2153] Fix | Delete
*
[2154] Fix | Delete
* // Hand it back to user's browser with appropriate content-type
[2155] Fix | Delete
* //
[2156] Fix | Delete
* header("Content-Type: " . $doc->content_type);
[2157] Fix | Delete
* $output = fopen("php://output", "w");
[2158] Fix | Delete
* $doc->stream($output); # stream object content to PHP's output buffer
[2159] Fix | Delete
* fclose($output);
[2160] Fix | Delete
* ?>
[2161] Fix | Delete
*
[2162] Fix | Delete
* # See read() above for a more simple example.
[2163] Fix | Delete
* #
[2164] Fix | Delete
* </code>
[2165] Fix | Delete
*
[2166] Fix | Delete
* @param resource $fp open resource for writing data to
[2167] Fix | Delete
* @param array $hdrs user-defined headers (Range, If-Match, etc.)
[2168] Fix | Delete
* @return string Object's data
[2169] Fix | Delete
* @throws InvalidResponseException unexpected response
[2170] Fix | Delete
*/
[2171] Fix | Delete
function stream(&$fp, $hdrs=array())
[2172] Fix | Delete
{
[2173] Fix | Delete
list($status, $reason) =
[2174] Fix | Delete
$this->container->cfs_http->get_object_to_stream($this,$fp,$hdrs);
[2175] Fix | Delete
#if ($status == 401 && $this->_re_auth()) {
[2176] Fix | Delete
# return $this->stream($fp, $hdrs);
[2177] Fix | Delete
#}
[2178] Fix | Delete
if (($status < 200) || ($status > 299
[2179] Fix | Delete
&& $status != 412 && $status != 304)) {
[2180] Fix | Delete
throw new InvalidResponseException("Invalid response (".$status."): "
[2181] Fix | Delete
.$reason);
[2182] Fix | Delete
}
[2183] Fix | Delete
return True;
[2184] Fix | Delete
}
[2185] Fix | Delete
[2186] Fix | Delete
/**
[2187] Fix | Delete
* Store new Object metadata
[2188] Fix | Delete
*
[2189] Fix | Delete
* Write's an Object's metadata to the remote Object. This will overwrite
[2190] Fix | Delete
* an prior Object metadata.
[2191] Fix | Delete
*
[2192] Fix | Delete
* Example:
[2193] Fix | Delete
* <code>
[2194] Fix | Delete
* # ... authentication/connection/container code excluded
[2195] Fix | Delete
* # ... see previous examples
[2196] Fix | Delete
*
[2197] Fix | Delete
* $my_docs = $conn->get_container("documents");
[2198] Fix | Delete
* $doc = $my_docs->get_object("README");
[2199] Fix | Delete
*
[2200] Fix | Delete
* # Define new metadata for the object
[2201] Fix | Delete
* #
[2202] Fix | Delete
* $doc->metadata = array(
[2203] Fix | Delete
* "Author" => "EJ",
[2204] Fix | Delete
* "Subject" => "How to use the PHP tests",
[2205] Fix | Delete
* "Version" => "1.2.2"
[2206] Fix | Delete
* );
[2207] Fix | Delete
*
[2208] Fix | Delete
* # Define additional headers for the object
[2209] Fix | Delete
* #
[2210] Fix | Delete
* $doc->headers = array(
[2211] Fix | Delete
* "Content-Disposition" => "attachment",
[2212] Fix | Delete
* );
[2213] Fix | Delete
*
[2214] Fix | Delete
* # Push the new metadata up to the storage system
[2215] Fix | Delete
* #
[2216] Fix | Delete
* $doc->sync_metadata();
[2217] Fix | Delete
* </code>
[2218] Fix | Delete
*
[2219] Fix | Delete
* @return boolean <kbd>True</kbd> if successful, <kbd>False</kbd> otherwise
[2220] Fix | Delete
* @throws InvalidResponseException unexpected response
[2221] Fix | Delete
*/
[2222] Fix | Delete
function sync_metadata()
[2223] Fix | Delete
{
[2224] Fix | Delete
if (!empty($this->metadata) || !empty($this->headers) || $this->manifest) {
[2225] Fix | Delete
$status = $this->container->cfs_http->update_object($this);
[2226] Fix | Delete
#if ($status == 401 && $this->_re_auth()) {
[2227] Fix | Delete
# return $this->sync_metadata();
[2228] Fix | Delete
#}
[2229] Fix | Delete
if ($status != 202) {
[2230] Fix | Delete
throw new InvalidResponseException("Invalid response ("
[2231] Fix | Delete
.$status."): ".$this->container->cfs_http->get_error());
[2232] Fix | Delete
}
[2233] Fix | Delete
return True;
[2234] Fix | Delete
}
[2235] Fix | Delete
return False;
[2236] Fix | Delete
}
[2237] Fix | Delete
/**
[2238] Fix | Delete
* Store new Object manifest
[2239] Fix | Delete
*
[2240] Fix | Delete
* Write's an Object's manifest to the remote Object. This will overwrite
[2241] Fix | Delete
* an prior Object manifest.
[2242] Fix | Delete
*
[2243] Fix | Delete
* Example:
[2244] Fix | Delete
* <code>
[2245] Fix | Delete
* # ... authentication/connection/container code excluded
[2246] Fix | Delete
* # ... see previous examples
[2247] Fix | Delete
*
[2248] Fix | Delete
* $my_docs = $conn->get_container("documents");
[2249] Fix | Delete
* $doc = $my_docs->get_object("README");
[2250] Fix | Delete
*
[2251] Fix | Delete
* # Define new manifest for the object
[2252] Fix | Delete
* #
[2253] Fix | Delete
* $doc->manifest = "container/prefix";
[2254] Fix | Delete
*
[2255] Fix | Delete
* # Push the new manifest up to the storage system
[2256] Fix | Delete
* #
[2257] Fix | Delete
* $doc->sync_manifest();
[2258] Fix | Delete
* </code>
[2259] Fix | Delete
*
[2260] Fix | Delete
* @return boolean <kbd>True</kbd> if successful, <kbd>False</kbd> otherwise
[2261] Fix | Delete
* @throws InvalidResponseException unexpected response
[2262] Fix | Delete
*/
[2263] Fix | Delete
[2264] Fix | Delete
function sync_manifest()
[2265] Fix | Delete
{
[2266] Fix | Delete
return $this->sync_metadata();
[2267] Fix | Delete
}
[2268] Fix | Delete
/**
[2269] Fix | Delete
* Upload Object's data to Cloud Files
[2270] Fix | Delete
*
[2271] Fix | Delete
* Write data to the remote Object. The $data argument can either be a
[2272] Fix | Delete
* PHP resource open for reading (see PHP's fopen() method) or an in-memory
[2273] Fix | Delete
* variable. If passing in a PHP resource, you must also include the $bytes
[2274] Fix | Delete
* parameter.
[2275] Fix | Delete
*
[2276] Fix | Delete
* Example:
[2277] Fix | Delete
* <code>
[2278] Fix | Delete
* # ... authentication/connection/container code excluded
[2279] Fix | Delete
* # ... see previous examples
[2280] Fix | Delete
*
[2281] Fix | Delete
* $my_docs = $conn->get_container("documents");
[2282] Fix | Delete
* $doc = $my_docs->get_object("README");
[2283] Fix | Delete
*
[2284] Fix | Delete
* # Upload placeholder text in my README
[2285] Fix | Delete
* #
[2286] Fix | Delete
* $doc->write("This is just placeholder text for now...");
[2287] Fix | Delete
* </code>
[2288] Fix | Delete
*
[2289] Fix | Delete
* @param string|resource $data string or open resource
[2290] Fix | Delete
* @param float $bytes amount of data to upload (required for resources)
[2291] Fix | Delete
* @param boolean $verify generate, send, and compare MD5 checksums
[2292] Fix | Delete
* @return boolean <kbd>True</kbd> when data uploaded successfully
[2293] Fix | Delete
* @throws SyntaxException missing required parameters
[2294] Fix | Delete
* @throws BadContentTypeException if no Content-Type was/could be set
[2295] Fix | Delete
* @throws MisMatchedChecksumException $verify is set and checksums unequal
[2296] Fix | Delete
* @throws InvalidResponseException unexpected response
[2297] Fix | Delete
*/
[2298] Fix | Delete
function write($data=NULL, $bytes=0, $verify=True)
[2299] Fix | Delete
{
[2300] Fix | Delete
if (!$data && !is_string($data)) {
[2301] Fix | Delete
throw new SyntaxException("Missing data source.");
[2302] Fix | Delete
}
[2303] Fix | Delete
if ($bytes > MAX_OBJECT_SIZE) {
[2304] Fix | Delete
throw new SyntaxException("Bytes exceeds maximum object size.");
[2305] Fix | Delete
}
[2306] Fix | Delete
if ($verify) {
[2307] Fix | Delete
if (!$this->_etag_override) {
[2308] Fix | Delete
$this->etag = $this->compute_md5sum($data);
[2309] Fix | Delete
}
[2310] Fix | Delete
} else {
[2311] Fix | Delete
$this->etag = NULL;
[2312] Fix | Delete
}
[2313] Fix | Delete
[2314] Fix | Delete
$close_fh = False;
[2315] Fix | Delete
if (!is_resource($data)) {
[2316] Fix | Delete
# A hack to treat string data as a file handle. php://memory feels
[2317] Fix | Delete
# like a better option, but it seems to break on Windows so use
[2318] Fix | Delete
# a temporary file instead.
[2319] Fix | Delete
#
[2320] Fix | Delete
$fp = fopen("php://temp", "wb+");
[2321] Fix | Delete
#$fp = fopen("php://memory", "wb+");
[2322] Fix | Delete
fwrite($fp, $data, strlen($data));
[2323] Fix | Delete
rewind($fp);
[2324] Fix | Delete
$close_fh = True;
[2325] Fix | Delete
$this->content_length = (float) strlen($data);
[2326] Fix | Delete
if ($this->content_length > MAX_OBJECT_SIZE) {
[2327] Fix | Delete
throw new SyntaxException("Data exceeds maximum object size");
[2328] Fix | Delete
}
[2329] Fix | Delete
$ct_data = substr($data, 0, 64);
[2330] Fix | Delete
} else {
[2331] Fix | Delete
// The original Rackspace library used rewind() instead of ftell/fseek here - which meant fseek(0), which was sometimes wrong
[2332] Fix | Delete
$fpos = ftell($data);
[2333] Fix | Delete
$this->content_length = $bytes;
[2334] Fix | Delete
$fp = $data;
[2335] Fix | Delete
$ct_data = fread($data, 64);
[2336] Fix | Delete
fseek($data, $fpos);
[2337] Fix | Delete
}
[2338] Fix | Delete
[2339] Fix | Delete
$this->_guess_content_type($ct_data);
[2340] Fix | Delete
[2341] Fix | Delete
list($status, $reason, $etag) =
[2342] Fix | Delete
$this->container->cfs_http->put_object($this, $fp);
[2343] Fix | Delete
#if ($status == 401 && $this->_re_auth()) {
[2344] Fix | Delete
# return $this->write($data, $bytes, $verify);
[2345] Fix | Delete
#}
[2346] Fix | Delete
if ($status == 412) {
[2347] Fix | Delete
if ($close_fh) { fclose($fp); }
[2348] Fix | Delete
throw new SyntaxException("Missing Content-Type header");
[2349] Fix | Delete
}
[2350] Fix | Delete
if ($status == 422) {
[2351] Fix | Delete
if ($close_fh) { fclose($fp); }
[2352] Fix | Delete
throw new MisMatchedChecksumException(
[2353] Fix | Delete
"Supplied and computed checksums do not match.");
[2354] Fix | Delete
}
[2355] Fix | Delete
if ($status != 201) {
[2356] Fix | Delete
if ($close_fh) { fclose($fp); }
[2357] Fix | Delete
throw new InvalidResponseException("Invalid response (".$status."): "
[2358] Fix | Delete
. $this->container->cfs_http->get_error());
[2359] Fix | Delete
}
[2360] Fix | Delete
if (!$verify) {
[2361] Fix | Delete
$this->etag = $etag;
[2362] Fix | Delete
}
[2363] Fix | Delete
if ($close_fh) { fclose($fp); }
[2364] Fix | Delete
return True;
[2365] Fix | Delete
}
[2366] Fix | Delete
[2367] Fix | Delete
/**
[2368] Fix | Delete
* Upload Object data from local filename
[2369] Fix | Delete
*
[2370] Fix | Delete
* This is a convenience function to upload the data from a local file. A
[2371] Fix | Delete
* True value for $verify will cause the method to compute the Object's MD5
[2372] Fix | Delete
* checksum prior to uploading.
[2373] Fix | Delete
*
[2374] Fix | Delete
* Example:
[2375] Fix | Delete
* <code>
[2376] Fix | Delete
* # ... authentication/connection/container code excluded
[2377] Fix | Delete
* # ... see previous examples
[2378] Fix | Delete
*
[2379] Fix | Delete
* $my_docs = $conn->get_container("documents");
[2380] Fix | Delete
* $doc = $my_docs->get_object("README");
[2381] Fix | Delete
*
[2382] Fix | Delete
* # Upload my local README's content
[2383] Fix | Delete
* #
[2384] Fix | Delete
* $doc->load_from_filename("/home/ej/cloudfiles/readme");
[2385] Fix | Delete
* </code>
[2386] Fix | Delete
*
[2387] Fix | Delete
* @param string $filename full path to local file
[2388] Fix | Delete
* @param boolean $verify enable local/remote MD5 checksum validation
[2389] Fix | Delete
* @return boolean <kbd>True</kbd> if data uploaded successfully
[2390] Fix | Delete
* @throws SyntaxException missing required parameters
[2391] Fix | Delete
* @throws BadContentTypeException if no Content-Type was/could be set
[2392] Fix | Delete
* @throws MisMatchedChecksumException $verify is set and checksums unequal
[2393] Fix | Delete
* @throws InvalidResponseException unexpected response
[2394] Fix | Delete
* @throws IOException error opening file
[2395] Fix | Delete
*/
[2396] Fix | Delete
function load_from_filename($filename, $verify=True)
[2397] Fix | Delete
{
[2398] Fix | Delete
$fp = @fopen($filename, "r");
[2399] Fix | Delete
if (!$fp) {
[2400] Fix | Delete
throw new IOException("Could not open file for reading: ".$filename);
[2401] Fix | Delete
}
[2402] Fix | Delete
[2403] Fix | Delete
clearstatcache();
[2404] Fix | Delete
[2405] Fix | Delete
$size = (float) sprintf("%u", filesize($filename));
[2406] Fix | Delete
if ($size > MAX_OBJECT_SIZE) {
[2407] Fix | Delete
throw new SyntaxException("File size exceeds maximum object size.");
[2408] Fix | Delete
}
[2409] Fix | Delete
[2410] Fix | Delete
$this->_guess_content_type($filename);
[2411] Fix | Delete
[2412] Fix | Delete
$this->write($fp, $size, $verify);
[2413] Fix | Delete
fclose($fp);
[2414] Fix | Delete
return True;
[2415] Fix | Delete
}
[2416] Fix | Delete
[2417] Fix | Delete
/**
[2418] Fix | Delete
* Save Object's data to local filename
[2419] Fix | Delete
*
[2420] Fix | Delete
* Given a local filename, the Object's data will be written to the newly
[2421] Fix | Delete
* created file.
[2422] Fix | Delete
*
[2423] Fix | Delete
* Example:
[2424] Fix | Delete
* <code>
[2425] Fix | Delete
* # ... authentication/connection/container code excluded
[2426] Fix | Delete
* # ... see previous examples
[2427] Fix | Delete
*
[2428] Fix | Delete
* # Whoops! I deleted my local README, let me download/save it
[2429] Fix | Delete
* #
[2430] Fix | Delete
* $my_docs = $conn->get_container("documents");
[2431] Fix | Delete
* $doc = $my_docs->get_object("README");
[2432] Fix | Delete
*
[2433] Fix | Delete
* $doc->save_to_filename("/home/ej/cloudfiles/readme.restored");
[2434] Fix | Delete
* </code>
[2435] Fix | Delete
*
[2436] Fix | Delete
* @param string $filename name of local file to write data to
[2437] Fix | Delete
* @return boolean <kbd>True</kbd> if successful
[2438] Fix | Delete
* @throws IOException error opening file
[2439] Fix | Delete
* @throws InvalidResponseException unexpected response
[2440] Fix | Delete
*/
[2441] Fix | Delete
function save_to_filename($filename)
[2442] Fix | Delete
{
[2443] Fix | Delete
$fp = @fopen($filename, "wb");
[2444] Fix | Delete
if (!$fp) {
[2445] Fix | Delete
throw new IOException("Could not open file for writing: ".$filename);
[2446] Fix | Delete
}
[2447] Fix | Delete
$result = $this->stream($fp);
[2448] Fix | Delete
fclose($fp);
[2449] Fix | Delete
return $result;
[2450] Fix | Delete
}
[2451] Fix | Delete
/**
[2452] Fix | Delete
* Purge this Object from CDN Cache.
[2453] Fix | Delete
* Example:
[2454] Fix | Delete
* <code>
[2455] Fix | Delete
* # ... authentication code excluded (see previous examples) ...
[2456] Fix | Delete
* #
[2457] Fix | Delete
* $conn = new CF_Connection($auth);
[2458] Fix | Delete
* $container = $conn->get_container("cdn_enabled");
[2459] Fix | Delete
* $obj = $container->get_object("object");
[2460] Fix | Delete
* $obj->purge_from_cdn("user@domain.com");
[2461] Fix | Delete
* # or
[2462] Fix | Delete
* $obj->purge_from_cdn();
[2463] Fix | Delete
* # or
[2464] Fix | Delete
* $obj->purge_from_cdn("user1@domain.com,user2@domain.com");
[2465] Fix | Delete
* </code>
[2466] Fix | Delete
* @returns boolean True if successful
[2467] Fix | Delete
* @throws CDNNotEnabledException if CDN Is not enabled on this connection
[2468] Fix | Delete
* @throws InvalidResponseException if the response expected is not returned
[2469] Fix | Delete
*/
[2470] Fix | Delete
function purge_from_cdn($email=null)
[2471] Fix | Delete
{
[2472] Fix | Delete
if (!$this->container->cfs_http->getCDNMUrl())
[2473] Fix | Delete
{
[2474] Fix | Delete
throw new CDNNotEnabledException(
[2475] Fix | Delete
"Authentication response did not indicate CDN availability");
[2476] Fix | Delete
}
[2477] Fix | Delete
$status = $this->container->cfs_http->purge_from_cdn($this->container->name . "/" . $this->name, $email);
[2478] Fix | Delete
if ($status < 199 or $status > 299) {
[2479] Fix | Delete
throw new InvalidResponseException(
[2480] Fix | Delete
"Invalid response (".$status."): ".$this->container->cfs_http->get_error());
[2481] Fix | Delete
}
[2482] Fix | Delete
return True;
[2483] Fix | Delete
}
[2484] Fix | Delete
[2485] Fix | Delete
/**
[2486] Fix | Delete
* Set Object's MD5 checksum
[2487] Fix | Delete
*
[2488] Fix | Delete
* Manually set the Object's ETag. Including the ETag is mandatory for
[2489] Fix | Delete
* Cloud Files to perform end-to-end verification. Omitting the ETag forces
[2490] Fix | Delete
* the user to handle any data integrity checks.
[2491] Fix | Delete
*
[2492] Fix | Delete
* @param string $etag MD5 checksum hexidecimal string
[2493] Fix | Delete
*/
[2494] Fix | Delete
function set_etag($etag)
[2495] Fix | Delete
{
[2496] Fix | Delete
$this->etag = $etag;
[2497] Fix | Delete
$this->_etag_override = True;
[2498] Fix | Delete
}
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function