forked from notmyname/php-cloudfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_cloudfiles.php.html
More file actions
235 lines (217 loc) · 16.8 KB
/
_cloudfiles.php.html
File metadata and controls
235 lines (217 loc) · 16.8 KB
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
<html>
<head>
<title>Docs for page cloudfiles.php</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
<tr>
<td class="header_top">php-cloudfiles</td>
</tr>
<tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt="" /></td></tr>
<tr>
<td class="header_menu">
[ <a href="../classtrees_php-cloudfiles.html" class="menu">class tree: php-cloudfiles</a> ]
[ <a href="../elementindex_php-cloudfiles.html" class="menu">index: php-cloudfiles</a> ]
[ <a href="../elementindex.html" class="menu">all elements</a> ]
</td>
</tr>
<tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt="" /></td></tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="200" class="menu">
<div id="ric">
<p><a href="../ric_README.html">README</a></p>
<p><a href="../ric_Changelog.html">Changelog</a></p>
<p><a href="../ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="../ric_COPYING.html">COPYING</a></p>
</div>
<b>Packages:</b><br />
<a href="../li_php-cloudfiles.html">php-cloudfiles</a><br />
<a href="../li_php-cloudfiles-exceptions.html">php-cloudfiles-exceptions</a><br />
<a href="../li_php-cloudfiles-http.html">php-cloudfiles-http</a><br />
<br /><br />
<b>Files:</b><br />
<div class="package">
<a href="../php-cloudfiles/_cloudfiles.php.html"> cloudfiles.php
</a><br>
</div><br />
<b>Classes:</b><br />
<div class="package">
<a href="../php-cloudfiles/CF_Authentication.html">CF_Authentication</a><br />
<a href="../php-cloudfiles/CF_Connection.html">CF_Connection</a><br />
<a href="../php-cloudfiles/CF_Container.html">CF_Container</a><br />
<a href="../php-cloudfiles/CF_Object.html">CF_Object</a><br />
</div>
</td>
<td>
<table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">
<h1>Procedural File: cloudfiles.php</h1>
Source Location: /cloudfiles.php<br /><br />
<br>
<br>
<div class="contents">
<h2>Classes:</h2>
<dt><a href="../php-cloudfiles/CF_Authentication.html">CF_Authentication</a></dt>
<dd>Class for handling Cloud Files Authentication, call it's <a href="../php-cloudfiles-http/CF_Http.html#methodauthenticate">authenticate()</a> method to obtain authorized service urls and an authentication token.</dd>
<dt><a href="../php-cloudfiles/CF_Connection.html">CF_Connection</a></dt>
<dd>Class for establishing connections to the Cloud Files storage system.</dd>
<dt><a href="../php-cloudfiles/CF_Container.html">CF_Container</a></dt>
<dd>Container operations</dd>
<dt><a href="../php-cloudfiles/CF_Object.html">CF_Object</a></dt>
<dd>Object operations</dd>
</div><br /><br />
<h2>Page Details:</h2>
This is the PHP Cloud Files API.<br /><br /><p><ol><li><div class="src-line"> <span class="src-comm"># Authenticate to Cloud Files. The default is to automatically try</span></div></li>
<li><div class="src-line"> <span class="src-comm"># to re-authenticate if an authentication token expires.</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-comm"># NOTE: Some versions of cURL include an outdated certificate authority (CA)</span></div></li>
<li><div class="src-line"> <span class="src-comm"># file. This API ships with a newer version obtained directly from</span></div></li>
<li><div class="src-line"> <span class="src-comm"># cURL's web site (http://curl.haxx.se). To use the newer CA bundle,</span></div></li>
<li><div class="src-line"> <span class="src-comm"># call the CF_Authentication instance's 'ssl_use_cabundle()' method.</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-var">$auth </span>= <span class="src-key">new </span><span class="src-id"><a href="../php-cloudfiles/CF_Authentication.html">CF_Authentication</a></span><span class="src-sym">(</span><span class="src-var">$username</span><span class="src-sym">, </span><span class="src-var">$api_key</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> <span class="src-comm"># $auth->ssl_use_cabundle(); # bypass cURL's old CA bundle</span></div></li>
<li><div class="src-line"> <span class="src-var">$auth</span><span class="src-sym">-></span><span class="src-id">authenticate</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"> <span class="src-comm"># Establish a connection to the storage system</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-comm"># NOTE: Some versions of cURL include an outdated certificate authority (CA)</span></div></li>
<li><div class="src-line"> <span class="src-comm"># file. This API ships with a newer version obtained directly from</span></div></li>
<li><div class="src-line"> <span class="src-comm"># cURL's web site (http://curl.haxx.se). To use the newer CA bundle,</span></div></li>
<li><div class="src-line"> <span class="src-comm"># call the CF_Connection instance's 'ssl_use_cabundle()' method.</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-var">$conn </span>= <span class="src-key">new </span><span class="src-id"><a href="../php-cloudfiles/CF_Connection.html">CF_Connection</a></span><span class="src-sym">(</span><span class="src-var">$auth</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> <span class="src-comm"># $conn->ssl_use_cabundle(); # bypass cURL's old CA bundle</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"> <span class="src-comm"># Create a remote Container and storage Object</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-var">$images </span>= <span class="src-var">$conn</span><span class="src-sym">-></span><span class="src-id">create_container</span><span class="src-sym">(</span><span class="src-str">"photos"</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> <span class="src-var">$bday </span>= <span class="src-var">$images</span><span class="src-sym">-></span><span class="src-id">create_object</span><span class="src-sym">(</span><span class="src-str">"first_birthday.jpg"</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"> <span class="src-comm"># Upload content from a local file by streaming it. Note that we use</span></div></li>
<li><div class="src-line"> <span class="src-comm"># a "float" for the file size to overcome PHP's 32-bit integer limit for</span></div></li>
<li><div class="src-line"> <span class="src-comm"># very large files.</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-var">$fname </span>= <span class="src-str">"/home/user/photos/birthdays/birthday1.jpg"</span><span class="src-sym">; </span><span class="src-comm"># filename to upload</span></div></li>
<li><div class="src-line"> <span class="src-var">$size </span>= (float) <a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-str">"%u"</span><span class="src-sym">, </span><a href="http://www.php.net/filesize">filesize</a><span class="src-sym">(</span><span class="src-var">$fname</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> <span class="src-var">$fp </span>= <span class="src-id">open</span><span class="src-sym">(</span><span class="src-var">$fname</span><span class="src-sym">, </span><span class="src-str">"r"</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> <span class="src-var">$bday</span><span class="src-sym">-></span><span class="src-id">write</span><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">, </span><span class="src-var">$size</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"> <span class="src-comm"># Or... use a convenience function instead</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-var">$bday</span><span class="src-sym">-></span><span class="src-id">load_from_filename</span><span class="src-sym">(</span><span class="src-str">"/home/user/photos/birthdays/birthday1.jpg"</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"> <span class="src-comm"># Now, publish the "photos" container to serve the images by CDN.</span></div></li>
<li><div class="src-line"> <span class="src-comm"># Use the "$uri" value to put in your web pages or send the link in an</span></div></li>
<li><div class="src-line"> <span class="src-comm"># email message, etc.</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> <span class="src-var">$uri </span>= <span class="src-var">$images</span><span class="src-sym">-></span><span class="src-id">make_public</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"> </div></li>
<li><div class="src-line"> <span class="src-comm"># Or... print out the Object's public URI</span></div></li>
<li><div class="src-line"> <span class="src-comm">#</span></div></li>
<li><div class="src-line"> print <span class="src-var">$bday</span><span class="src-sym">-></span><span class="src-id">public_uri</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol></p><p>See the included tests directory for additional sample code.</p><p>Requres PHP 5.x (for Exceptions and OO syntax) and PHP's cURL module.</p><p>It uses the supporting "cloudfiles_http.php" module for HTTP(s) support and allows for connection re-use and streaming of content into/out of Cloud Files via PHP's cURL module.</p><p>See COPYING for license information.</p><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>author:</b> </td><td>Eric "EJ" Johnson <<a href="mailto:ej@racklabs.com">ej@racklabs.com</a>></td>
</tr>
<tr>
<td><b>copyright:</b> </td><td>Copyright (c) 2008, Rackspace US, Inc.</td>
</tr>
</table>
</div>
<br /><br />
<h4>Includes:</h4>
<div class="tags">
require(<a href="../php-cloudfiles-http/_cloudfiles_http.php.html">"cloudfiles_http.php"</a>) [line 75]<br />
require_once(<a href="../php-cloudfiles-exceptions/_cloudfiles_exceptions.php.html">"cloudfiles_exceptions.php"</a>) [line 74]<br />
</div>
<br /><br />
<br /><br />
<hr />
<a name="defineDEFAULT_CF_API_VERSION"></a>
<h3>DEFAULT_CF_API_VERSION <span class="smalllinenumber">[line 76]</span></h3>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>DEFAULT_CF_API_VERSION = 1</code>
</td></tr></table>
</td></tr></table>
<br />
</div>
<div class="top">[ <a href="#top">Top</a> ]</div><br /><br />
<hr />
<a name="defineMAX_CONTAINER_NAME_LEN"></a>
<h3>MAX_CONTAINER_NAME_LEN <span class="smalllinenumber">[line 77]</span></h3>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>MAX_CONTAINER_NAME_LEN = 256</code>
</td></tr></table>
</td></tr></table>
<br />
</div>
<div class="top">[ <a href="#top">Top</a> ]</div><br /><br />
<hr />
<a name="defineMAX_OBJECT_NAME_LEN"></a>
<h3>MAX_OBJECT_NAME_LEN <span class="smalllinenumber">[line 78]</span></h3>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>MAX_OBJECT_NAME_LEN = 1024</code>
</td></tr></table>
</td></tr></table>
<br />
</div>
<div class="top">[ <a href="#top">Top</a> ]</div><br /><br />
<hr />
<a name="defineMAX_OBJECT_SIZE"></a>
<h3>MAX_OBJECT_SIZE <span class="smalllinenumber">[line 79]</span></h3>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>MAX_OBJECT_SIZE = 5*1024*1024*1024+1</code>
</td></tr></table>
</td></tr></table>
<br />
</div>
<div class="top">[ <a href="#top">Top</a> ]</div><br /><br />
<hr />
<a name="defineUK_AUTHURL"></a>
<h3>UK_AUTHURL <span class="smalllinenumber">[line 81]</span></h3>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>UK_AUTHURL = "https://lon.auth.api.rackspacecloud.com"</code>
</td></tr></table>
</td></tr></table>
<br />
</div>
<div class="top">[ <a href="#top">Top</a> ]</div><br /><br />
<hr />
<a name="defineUS_AUTHURL"></a>
<h3>US_AUTHURL <span class="smalllinenumber">[line 80]</span></h3>
<div class="tags">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>US_AUTHURL = "https://auth.api.rackspacecloud.com"</code>
</td></tr></table>
</td></tr></table>
<br />
</div>
<div class="top">[ <a href="#top">Top</a> ]</div><br /><br />
<br />
<div class="credit">
<hr />
Documentation generated on Wed, 07 Sep 2011 15:19:54 -0500 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
</tr>
</table>
</body>
</html>