1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916
|
<?xml version="1.0" encoding="utf-8"?>
<sect1 id="zend.service.rackspace.files">
<title>Zend_Service_Rackspace_Files</title>
<sect2 id="zend.service.rackspace.files.intro">
<title>Overview</title>
<para>
The <classname>Zend_Service_Rackspace_Files</classname> is a class that provides a
simple <acronym>API</acronym> to manage the <ulink url="http://www.rackspace.com/cloud/cloud_hosting_products/files/">Rackspace
Cloud Files</ulink>.
</para>
</sect2>
<sect2 id="zend.service.rackspace.files.quick-start">
<title>Quick Start</title>
<para>
To use this class you have to pass the username and the API's key of Rackspace in the
construction of the class.
</para>
<programlisting language="php"><![CDATA[
$user = 'username';
$key = 'secret key';
$rackspace = new Zend_Service_Rackspace_Files($user,$key);
]]></programlisting>
<para>
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. You can, however, create an unlimited number of containers
within your account. Data must be stored in a container so you must have at least one
container defined in your account prior to uploading data.
</para>
<para>
The only restrictions on container names is that they cannot contain a forward slash (/)
and must be less than 256 bytes in length (please note that the length restriction applies to
the name using the URL encoded format).
</para>
<para>
The containers are managed using the class <classname>Zend_Service_Rackspace_Files_Container</classname>.
</para>
<para>
An object (file) is the basic storage entity and any optional metadata that represents the files
you store in the Cloud Files system. When you upload data to Cloud Files, the data is stored
as-is (no compression or encryption) and consists of a location (container), the object's
name, and any metadata consisting of key/value pairs. For instance, you may chose to store
a backup of your digital photos and organize them into albums. In this case, each object
could be tagged with metadata such as Album : Caribbean Cruise or Album :
Aspen Ski Trip.
</para>
<para>
The only restriction on object names is that they must be less than 1024 bytes in length
after URL encoding. Cloud Files has a limit on the size of a single uploaded object;
by default this is 5 GB. For metadata, you should not exceed 90 individual key/value pairs
for any one object and the total byte length of all key/value pairs should not exceed 4KB (4096 bytes).
</para>
<para>
The objects are managed using the class <classname>Zend_Service_Rackspace_Files_Object</classname>.
</para>
<para>
To create a new container you can use the <emphasis>createContainer</emphasis> method.
</para>
<programlisting language="php"><![CDATA[
$container= $rackspace->createContainer('test');
if (!$rackspace->isSuccessful()) {
die('ERROR: '.$rackspace->getErrorMsg());
}
printf("Name: %s",$container->getName());
]]></programlisting>
<para>
This example create a container with name <emphasis>test</emphasis>. The result of <emphasis>createContainer</emphasis>
is a new instance of <classname>Zend_Service_Rackspace_Files_Container</classname>.
</para>
<para>
To store an object (file) in a container you can use the <emphasis>storeObject</emphasis> method.
</para>
<programlisting language="php"><![CDATA[
$name= 'example.jpg';
$file= file_get_contents($name);
$metadata= array (
'foo' => 'bar'
);
$rackspace->storeObject('test',$name,$file,$metadata);
if ($rackspace->isSuccessful()) {
echo 'Object stored successfully';
} else {
printf("ERROR: %s",$rackspace->getErrorMsg());
}
]]></programlisting>
<para>
This example store a file image <emphasis>example.jpg</emphasis> in the container <emphasis>test</emphasis>
with the metadata specified in the array <emphasis>$metadata</emphasis>.
</para>
<para>
To delete an object (file) you can use the <emphasis>deleteObject</emphasis> method.
</para>
<programlisting language="php"><![CDATA[
$rackspace->deleteObject('test','example.jpg');
if ($rackspace->isSuccessful()) {
echo 'Object deleted successfully';
} else {
printf("ERROR: %s",$rackspace->getErrorMsg());
}
]]></programlisting>
<para>
This example delete the object <emphasis>example.jpg</emphasis> in the container <emphasis>test</emphasis>.
</para>
<para>
To publish a container as <acronym>CDN</acronym> (Content Delivery Network) you can use the <emphasis>enableCdnContainer</emphasis> method.
</para>
<programlisting language="php"><![CDATA[
$cdnInfo= $rackspace->enableCdnContainer('test');
if ($rackspace->isSuccessful()) {
print_r($cdnInfo);
} else {
printf("ERROR: %s",$rackspace->getErrorMsg());
}
]]></programlisting>
<para>
This example publish the container <emphasis>test</emphasis> as <acronym>CDN</acronym>.
If the operation is successfull returns an associative arrays with the following values:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>cdn_uri</emphasis>, the url of the CDN container;
</para>
</listitem>
<listitem>
<para>
<emphasis>cdn_uri_ssl</emphasis>, the ssl url of the CDN container;
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 id="zend.service.rackspace.files.methods">
<title>Available Methods</title>
<variablelist>
<varlistentry id="zend.service.rackspace.files.methods.copy-object">
<term>
<methodsynopsis>
<methodname>copyObject</methodname>
<methodparam>
<funcparams>string $container_source,string $obj_source,string $container_dest,string $obj_dest,$metadata=array(),string $content_type=null</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Copy an object from a container to another.
The return is <emphasis>true</emphasis> in case of success and <emphasis>false</emphasis> in case of error.
</para>
<para>
The <emphasis>$container_source</emphasis> is the name of the source container.
</para>
<para>
The <emphasis>$obj_source</emphasis> is the name of the source object.
</para>
<para>
The <emphasis>$container_dest</emphasis> is the name of the destination container.
</para>
<para>
The <emphasis>$obj_dest</emphasis> is the name of the destination object.
</para>
<para>
The <emphasis>$metadata</emphasis> array contains the metadata information related to the destination object.
</para>
<para>
The <emphasis>$content_type</emphasis> is the optional content type of the destination object (file).
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.create-container">
<term>
<methodsynopsis>
<methodname>createContainer</methodname>
<methodparam>
<funcparams>string $container, $metadata=array()</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Create a container. The return is an instance of <classname>Zend_Service_Rackspace_Files_Container</classname>.
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container to create.
</para>
<para>
The <emphasis>$metadata</emphasis> array contains the metadata information related to the container.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.delete-container">
<term>
<methodsynopsis>
<methodname>deleteContainer</methodname>
<methodparam>
<funcparams>string $container</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Delete a container. The return is <emphasis>true</emphasis> in case of success and <emphasis>false</emphasis> in case of error.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container to delete.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.delete-object">
<term>
<methodsynopsis>
<methodname>deleteObject</methodname>
<methodparam>
<funcparams>string $container,string $object</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Delete an object in a specific container. Return <emphasis>true</emphasis> in case of success, <emphasis>false</emphasis> in case of error.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$object</emphasis> is the name of the object to delete.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.enable-cdn-container">
<term>
<methodsynopsis>
<methodname>enableCdnContainer</methodname>
<methodparam>
<funcparams>string $container,integer $ttl=900</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Publish a container as <acronym>CDN</acronym> (Content Delivery Network). Return an associative array contains the CDN url and SSL url.
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$ttl</emphasis> is the time to live for the CDN cache content. The default value is 15 minutes (900 seconds).
The minimum TTL that can be set is 15 minutes (900 seconds); the maximum TTL is
50 years (range of 900 to 1577836800 seconds).
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-cdn-containers">
<term>
<methodsynopsis>
<methodname>getCdnContainers</methodname>
<methodparam>
<funcparams>$options=array()</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Returns all the CDN containers available. The return is an instance of <classname>Zend_Service_Rackspace_Files_ContainerList</classname>.
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$options</emphasis> contains the following optional parameters:
<itemizedlist>
<listitem>
<para>
<emphasis>limit</emphasis>, for an integer value n, limits the number of results to at most n values.
</para>
</listitem>
<listitem>
<para>
<emphasis>marker</emphasis>, given a string value x, return object names greater in value than the specified marker.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-containers">
<term>
<methodsynopsis>
<methodname>getContainers</methodname>
<methodparam>
<funcparams>$options=array()</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Returns all the containers available. The return is an instance of <classname>Zend_Service_Rackspace_Files_ContainerList</classname>
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$options</emphasis> contains the following optional parameters:
<itemizedlist>
<listitem>
<para>
<emphasis>limit</emphasis>, for an integer value n, limits the number of results to at most n values.
</para>
</listitem>
<listitem>
<para>
<emphasis>marker</emphasis>, given a string value x, return object names greater in value than the specified marker.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-container">
<term>
<methodsynopsis>
<methodname>getContainer</methodname>
<methodparam>
<funcparams>string $container</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Returns the container specified as instance of <classname>Zend_Service_Rackspace_Files_Container</classname>
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-count-containers">
<term>
<methodsynopsis>
<methodname>getCountContainers</methodname>
<methodparam>
<funcparams/>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Return the total count of containers.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-count-objects">
<term>
<methodsynopsis>
<methodname>getCountObjects</methodname>
<methodparam>
<funcparams/>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Return the count of objects contained in all the containers.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-info-cdn-container">
<term>
<methodsynopsis>
<methodname>getInfoCdnContainer</methodname>
<methodparam>
<funcparams>string $container</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Get the information of a CDN container. The result is an associative array with all the CDN information.
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-info-containers">
<term>
<methodsynopsis>
<methodname>getInfoContainers</methodname>
<methodparam>
<funcparams/>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Get the information about all the containers available.
Return an associative array with the following values:
<itemizedlist>
<listitem>
<para>
<emphasis>tot_containers</emphasis>, the total number of containers stored
</para>
</listitem>
<listitem>
<para>
<emphasis>size_containers</emphasis>, the total size, in byte, of all the containers.
</para>
</listitem>
<listitem>
<para>
<emphasis>tot_objects</emphasis>, the total number of objects (file) stored in all the containers.
</para>
</listitem>
</itemizedlist>
In case of error the return is <emphasis>false</emphasis>.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-metadata-container">
<term>
<methodsynopsis>
<methodname>getMetadataContainer</methodname>
<methodparam>
<funcparams>string $container</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Get the metadata information of a container. The result is an associative array with all the metadata keys/values.
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-metadata-object">
<term>
<methodsynopsis>
<methodname>getMetadataObject</methodname>
<methodparam>
<funcparams>string $container, string $object</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Get the metadata information of an object. The result is an associative array with all the metadata keys/values.
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$object</emphasis> is the name of the object.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-objects">
<term>
<methodsynopsis>
<methodname>getObjects</methodname>
<methodparam>
<funcparams>string $container, $options=array()</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Returns all the objects of a container. The return is an instance of <classname>Zend_Service_Rackspace_Files_ObjectList</classname>
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$options</emphasis> contains the following optional parameters:
<itemizedlist>
<listitem>
<para>
<emphasis>limit</emphasis>, for an integer value n, limits the number of results
to at most n values.
</para>
</listitem>
<listitem>
<para>
<emphasis>marker</emphasis>, given a string value x, return object names greater
in value than the specified marker.
</para>
</listitem>
<listitem>
<para>
<emphasis>prefix</emphasis>, for a string value x, causes the results to be
limited to object names beginning with the substring x.
</para>
</listitem>
<listitem>
<para>
<emphasis>path</emphasis>, for a string value x, return the object names nested
in the pseudo path.
</para>
</listitem>
<listitem>
<para>
<emphasis>delimiter</emphasis>, for a character c, return all the object names
nested in the container (without the need for the directory marker objects).
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-object">
<term>
<methodsynopsis>
<methodname>getObject</methodname>
<methodparam>
<funcparams>string $container, string $object, $headers=array()</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Returns an object of a container. The return is an instance of <classname>Zend_Service_Rackspace_Files_Object</classname>
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$object</emphasis> is the name of the object.
</para>
<para>
The <emphasis>$headers</emphasis> contains the following optional parameters (See the <ulink url="http://www.ietf.org/rfc/rfc2616.txt">RFC-2616</ulink> for more info):
<itemizedlist>
<listitem>
<para>
<emphasis>If-Match</emphasis>, a client that has one or more entities previously
obtained from the resource can verify that one of those entities is
current by including a list of their associated entity tags in the
If-Match header field.
</para>
</listitem>
<listitem>
<para>
<emphasis>If-None-Match</emphasis>, a client that has one or more entities previously
obtained from the resource can verify that none of those entities is
current by including a list of their associated entity tags in the
If-None-Match header field.
</para>
</listitem>
<listitem>
<para>
<emphasis>If-Modified-Since</emphasis>, if the requested variant has not been modified
since the time specified in this field, an entity will not be returned from the server.
</para>
</listitem>
<listitem>
<para>
<emphasis>If-Unmodified-Since</emphasis>, if the requested resource has not been modified
since the time specified in this field, the server SHOULD perform the
requested operation as if the If-Unmodified-Since header were not present.
</para>
</listitem>
<listitem>
<para>
<emphasis>Range</emphasis>, Rackspace supports a sub-set of Range and do not adhere to the full RFC-2616 specification. We support
specifying OFFSET-LENGTH where either OFFSET or LENGTH can be optional (not both at
the same time). The following are supported forms of the header:
<itemizedlist>
<listitem>
<para>
<emphasis>Range: bytes=-5</emphasis>, last five bytes of the object
</para>
</listitem>
<listitem>
<para>
<emphasis>Range: bytes=10-15</emphasis>, the five bytes after a 10-byte offset
</para>
</listitem>
<listitem>
<para>
<emphasis>Range: bytes=32-</emphasis>, all data after the first 32 bytes of the object
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.get-size-containers">
<term>
<methodsynopsis>
<methodname>getSizeContainers</methodname>
<methodparam>
<funcparams/>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Return the size, in bytes, of all the containers.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.set-metadata-object">
<term>
<methodsynopsis>
<methodname>setMetadataObject</methodname>
<methodparam>
<funcparams>string $container,string $object, array $metadata</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Update metadata information to the object (all the previous metadata will be deleted).
Return <emphasis>true</emphasis> in case of success, <emphasis>false</emphasis> in case of error.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$object</emphasis> is the name of the object to store.
</para>
<para>
The <emphasis>$metadata</emphasis> array contains the metadata information related to the object.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.store-object">
<term>
<methodsynopsis>
<methodname>storeObject</methodname>
<methodparam>
<funcparams>string $container,string $object,string $file,$metadata=array()</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Store an object in a specific container. Return <emphasis>true</emphasis> in case of success, <emphasis>false</emphasis> in case of error.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$object</emphasis> is the name of the object to store.
</para>
<para>
The <emphasis>$file</emphasis> is the content of the object to store.
</para>
<para>
The <emphasis>$metadata</emphasis> array contains the metadata information related to the object to store.
</para>
</listitem>
</varlistentry>
<varlistentry id="zend.service.rackspace.files.methods.update-cdn-container">
<term>
<methodsynopsis>
<methodname>updateCdnContainer</methodname>
<methodparam>
<funcparams>string $container,integer $ttl=null,$cdn_enabled=null,$log=null</funcparams>
</methodparam>
</methodsynopsis>
</term>
<listitem>
<para>
Update the attribute of a <acronym>CDN</acronym> container. Return an associative array contains the CDN url and SSL url.
In case of error the return is <emphasis>false</emphasis>.
</para>
<para>
The <emphasis>$container</emphasis> is the name of the container.
</para>
<para>
The <emphasis>$ttl</emphasis> is the time to live for the CDN cache content. The default value is 15 minutes (900 seconds).
The minimum TTL that can be set is 15 minutes (900 seconds); the maximum TTL is
50 years (range of 900 to 1577836800 seconds).
</para>
<para>
The <emphasis>$cdn_enabled</emphasis> is the flag to swith on/off the CDN. <emphasis>True</emphasis> switch on, <emphasis>false</emphasis> switch off.
</para>
<para>
The <emphasis>$log</emphasis> enable or disable the log retention. <emphasis>True</emphasis> switch on, <emphasis>false</emphasis> switch off.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 id="zend.service.rackspace.files.examples">
<title>Examples</title>
<example id="zend.service.rackspace.files.examples.authenticate">
<title>Authenticate</title>
<para>Check if the username and the key are valid for the Rackspace authentication.</para>
<programlisting language="php"><![CDATA[
$user = 'username';
$key = 'secret key';
$rackspace = new Zend_Service_Rackspace_Files($user,$key);
if ($rackspace->authenticate()) {
printf("Authenticated with token: %s",$rackspace->getToken());
} else {
printf("ERROR: %s",$rackspace->getErrorMsg());
}
]]></programlisting>
</example>
<example id="zend.service.rackspace.files.examples.get-object">
<title>Get an object</title>
<para>Get an image file (<emphasis>example.gif</emphasis>) from the cloud and render it in the browser</para>
<programlisting language="php"><![CDATA[
$user = 'username';
$key = 'secret key';
$rackspace = new Zend_Service_Rackspace_Files($user,$key);
$object= $rackspace->getObject('test','example.gif');
if (!$rackspace->isSuccessful()) {
die('ERROR: '.$rackspace->getErrorMsg());
}
header('Content-type: image/gif');
echo $object->getFile();
]]></programlisting>
</example>
<example id="zend.service.rackspace.files.examples.create-container">
<title>Create a container with metadata</title>
<para>Create a container (<emphasis>test</emphasis>) with some metadata information (<emphasis>$metadata</emphasis>)</para>
<programlisting language="php"><![CDATA[
$user = 'username';
$key = 'secret key';
$rackspace = new Zend_Service_Rackspace_Files($user,$key);
$metadata= array (
'foo' => 'bar',
'foo2' => 'bar2',
);
$container= $rackspace->createContainer('test',$metadata);
if ($rackspace->isSuccessful()) {
echo 'Container created successfully';
}
]]></programlisting>
</example>
<example id="zend.service.rackspace.files.examples.get-metadata-container">
<title>Get the metadata of a container</title>
<para>Get the metadata of the container <emphasis>test</emphasis></para>
<programlisting language="php"><![CDATA[
$user = 'username';
$key = 'secret key';
$rackspace = new Zend_Service_Rackspace_Files($user, $key);
$container= $rackspace->getContainer('test');
if (!$rackspace->isSuccessful()) {
die('ERROR: ' . $rackspace->getErrorMsg());
}
$metadata= $container->getMetadata();
print_r($metadata);
]]></programlisting>
</example>
<example id="zend.service.rackspace.files.examples.store-object-container">
<title>Store an object in a container</title>
<para>Store an object using a <classname>Zend_Service_Rackspace_Files_Container</classname> instance</para>
<programlisting language="php"><![CDATA[
$user = 'username';
$key = 'secret key';
$rackspace = new Zend_Service_Rackspace_Files($user, $key);
$container= $rackspace->getContainer('test');
if (!$rackspace->isSuccessful()) {
die('ERROR: ' . $rackspace->getErrorMsg());
}
$file = file_get_contents('test.jpg');
$metadata = array (
'foo' => 'bar',
);
if ($container->addObject('test.jpg', $file, $metadata)) {
echo 'Object stored successfully';
}
]]></programlisting>
</example>
<example id="zend.service.rackspace.files.examples.check-cdn-enabled">
<title>Check if a container is CDN enabled</title>
<para>Check if the <emphasis>test</emphasis> container is CDN enabled. If it is not we enable it.</para>
<programlisting language="php"><![CDATA[
$user = 'username';
$key = 'secret key';
$rackspace = new Zend_Service_Rackspace_Files($user, $key);
$container= $rackspace->getContainer('test');
if (!$rackspace->isSuccessful()) {
die('ERROR: ' . $rackspace->getErrorMsg());
}
if (!$container->isCdnEnabled()) {
if (!$container->enableCdn()) {
die('ERROR: ' . $rackspace->getErrorMsg());
}
}
printf(
"The container is CDN enabled with the following URLs:\n %s\n %s\n",
$container->getCdnUri(),
$container->getCdnUriSsl()
);
]]></programlisting>
</example>
</sect2>
</sect1>
|