Zend_Service_Rackspace_Files.xml 40 KB

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