libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1348696 - /libcloud/site/trunk/content/docs/storage-examples.mdtext
Date Mon, 11 Jun 2012 00:35:38 GMT
Author: tomaz
Date: Mon Jun 11 00:35:37 2012
New Revision: 1348696

URL: http://svn.apache.org/viewvc?rev=1348696&view=rev
Log:
Add 'Publishing a static website using CloudFiles driver' example to the docs.

Modified:
    libcloud/site/trunk/content/docs/storage-examples.mdtext

Modified: libcloud/site/trunk/content/docs/storage-examples.mdtext
URL: http://svn.apache.org/viewvc/libcloud/site/trunk/content/docs/storage-examples.mdtext?rev=1348696&r1=1348695&r2=1348696&view=diff
==============================================================================
--- libcloud/site/trunk/content/docs/storage-examples.mdtext (original)
+++ libcloud/site/trunk/content/docs/storage-examples.mdtext Mon Jun 11 00:35:37 2012
@@ -4,6 +4,7 @@ title: Storage -> Examples
 
 * [Create a backup of a directory and directly stream it to CloudFiles](#example-1-streaming-upload)
 * [Efficiently download multiple files using gevent](#efficiently-download-multiple-files-using-gevent)
+* [Publishing a static website using CloudFiles driver](#publishing-a-static-website-using-cloudfiles-driver)
 
 <h3 id="example-1-streaming-upload">Create a backup of a directory and directly stream
it to CloudFiles</h3>
 
@@ -81,3 +82,37 @@ title: Storage -> Examples
 
     pool.join()
     print 'Done'
+
+<h3 id="publishing-a-static-website-using-cloudfiles-driver">Publishing a static website
using CloudFiles driver</h3>
+
+Note this feature is currently only available in Libcloud `trunk`.
+
+    ::python
+    from StringIO import StringIO
+
+    from libcloud.storage.types import Provider
+    from libcloud.storage.providers import get_driver
+
+    CloudFiles = get_driver(Provider.CLOUDFILES_US)
+
+    driver = CloudFiles('username', 'api key')
+
+    container = driver.create_container(container_name='my_website')
+
+    iterator1 = StringIO('<p>Hello World from Libcloud!</p>')
+    iterator2 = StringIO('<p>Oh, noez, 404!!</p>')
+    iterator3 = StringIO('<p>Oh, noez, 401!!</p>')
+
+    driver.upload_object_via_stream(iterator=iterator1, container=container,
+                                    object_name='index.html')
+    driver.upload_object_via_stream(iterator=iterator2, container=container,
+                                    object_name='404error.html')
+    driver.upload_object_via_stream(iterator=iterator3, container=container,
+                                    object_name='401error.html')
+
+    driver.ex_enable_static_website(container=container)
+    driver.ex_set_error_page(container=container, file_name='error.html')
+    driver.enable_container_cdn(container=container)
+
+    print(All done you can view the website at', \
+          driver.get_container_cdn_url(container=container))



Mime
View raw message