libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r821194 - in /websites/staging/libcloud/trunk/content: ./ docs/storage-examples.html
Date Mon, 11 Jun 2012 00:35:43 GMT
Author: buildbot
Date: Mon Jun 11 00:35:43 2012
New Revision: 821194

Log:
Staging update by buildbot for libcloud

Modified:
    websites/staging/libcloud/trunk/content/   (props changed)
    websites/staging/libcloud/trunk/content/docs/storage-examples.html

Propchange: websites/staging/libcloud/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Jun 11 00:35:43 2012
@@ -1 +1 @@
-1348694
+1348696

Modified: websites/staging/libcloud/trunk/content/docs/storage-examples.html
==============================================================================
--- websites/staging/libcloud/trunk/content/docs/storage-examples.html (original)
+++ websites/staging/libcloud/trunk/content/docs/storage-examples.html Mon Jun 11 00:35:43
2012
@@ -97,6 +97,7 @@
 <ul>
 <li><a href="#example-1-streaming-upload">Create a backup of a directory and
directly stream it to CloudFiles</a></li>
 <li><a href="#efficiently-download-multiple-files-using-gevent">Efficiently download
multiple files using gevent</a></li>
+<li><a href="#publishing-a-static-website-using-cloudfiles-driver">Publishing
a static website using CloudFiles driver</a></li>
 </ul>
 <h3 id="example-1-streaming-upload">Create a backup of a directory and directly stream
it to CloudFiles</h3>
 
@@ -175,6 +176,40 @@
 <span class="n">pool</span><span class="o">.</span><span class="n">join</span><span
class="p">()</span>
 <span class="k">print</span> <span class="s">&#39;Done&#39;</span>
 </pre></div>
+
+
+<h3 id="publishing-a-static-website-using-cloudfiles-driver">Publishing a static website
using CloudFiles driver</h3>
+
+<p>Note this feature is currently only available in Libcloud <code>trunk</code>.</p>
+<div class="codehilite"><pre><span class="kn">from</span> <span
class="nn">StringIO</span> <span class="kn">import</span> <span class="n">StringIO</span>
+
+<span class="kn">from</span> <span class="nn">libcloud.storage.types</span>
<span class="kn">import</span> <span class="n">Provider</span>
+<span class="kn">from</span> <span class="nn">libcloud.storage.providers</span>
<span class="kn">import</span> <span class="n">get_driver</span>
+
+<span class="n">CloudFiles</span> <span class="o">=</span> <span
class="n">get_driver</span><span class="p">(</span><span class="n">Provider</span><span
class="o">.</span><span class="n">CLOUDFILES_US</span><span class="p">)</span>
+
+<span class="n">driver</span> <span class="o">=</span> <span class="n">CloudFiles</span><span
class="p">(</span><span class="s">&#39;username&#39;</span><span
class="p">,</span> <span class="s">&#39;api key&#39;</span><span
class="p">)</span>
+
+<span class="n">container</span> <span class="o">=</span> <span
class="n">driver</span><span class="o">.</span><span class="n">create_container</span><span
class="p">(</span><span class="n">container_name</span><span class="o">=</span><span
class="s">&#39;my_website&#39;</span><span class="p">)</span>
+
+<span class="n">iterator1</span> <span class="o">=</span> <span
class="n">StringIO</span><span class="p">(</span><span class="s">&#39;&lt;p&gt;Hello
World from Libcloud!&lt;/p&gt;&#39;</span><span class="p">)</span>
+<span class="n">iterator2</span> <span class="o">=</span> <span
class="n">StringIO</span><span class="p">(</span><span class="s">&#39;&lt;p&gt;Oh,
noez, 404!!&lt;/p&gt;&#39;</span><span class="p">)</span>
+<span class="n">iterator3</span> <span class="o">=</span> <span
class="n">StringIO</span><span class="p">(</span><span class="s">&#39;&lt;p&gt;Oh,
noez, 401!!&lt;/p&gt;&#39;</span><span class="p">)</span>
+
+<span class="n">driver</span><span class="o">.</span><span class="n">upload_object_via_stream</span><span
class="p">(</span><span class="n">iterator</span><span class="o">=</span><span
class="n">iterator1</span><span class="p">,</span> <span class="n">container</span><span
class="o">=</span><span class="n">container</span><span class="p">,</span>
+                                <span class="n">object_name</span><span class="o">=</span><span
class="s">&#39;index.html&#39;</span><span class="p">)</span>
+<span class="n">driver</span><span class="o">.</span><span class="n">upload_object_via_stream</span><span
class="p">(</span><span class="n">iterator</span><span class="o">=</span><span
class="n">iterator2</span><span class="p">,</span> <span class="n">container</span><span
class="o">=</span><span class="n">container</span><span class="p">,</span>
+                                <span class="n">object_name</span><span class="o">=</span><span
class="s">&#39;404error.html&#39;</span><span class="p">)</span>
+<span class="n">driver</span><span class="o">.</span><span class="n">upload_object_via_stream</span><span
class="p">(</span><span class="n">iterator</span><span class="o">=</span><span
class="n">iterator3</span><span class="p">,</span> <span class="n">container</span><span
class="o">=</span><span class="n">container</span><span class="p">,</span>
+                                <span class="n">object_name</span><span class="o">=</span><span
class="s">&#39;401error.html&#39;</span><span class="p">)</span>
+
+<span class="n">driver</span><span class="o">.</span><span class="n">ex_enable_static_website</span><span
class="p">(</span><span class="n">container</span><span class="o">=</span><span
class="n">container</span><span class="p">)</span>
+<span class="n">driver</span><span class="o">.</span><span class="n">ex_set_error_page</span><span
class="p">(</span><span class="n">container</span><span class="o">=</span><span
class="n">container</span><span class="p">,</span> <span class="n">file_name</span><span
class="o">=</span><span class="s">&#39;error.html&#39;</span><span
class="p">)</span>
+<span class="n">driver</span><span class="o">.</span><span class="n">enable_container_cdn</span><span
class="p">(</span><span class="n">container</span><span class="o">=</span><span
class="n">container</span><span class="p">)</span>
+
+<span class="k">print</span><span class="p">(</span><span class="n">All</span>
<span class="n">done</span> <span class="n">you</span> <span class="n">can</span>
<span class="n">view</span> <span class="n">the</span> <span class="n">website</span>
<span class="n">at</span><span class="s">&#39;, </span><span
class="se">\</span>
+<span class="s">      driver.get_container_cdn_url(container=container))</span>
+</pre></div>
       
     </div>
 



Mime
View raw message