SWIFT offers the possibility to serve data in containers as a static web site. This can be done by following the steps below.
First create a container
swift post static
Make sure that everythting is world readable
swift post -r '.r:*,.rlistings' static
If you want access paths that have an index.html without needing to type the index.html part, you you need to set an index file directive:
swift post -m 'web-index:index.html' static
Allow listing if no index.html file exists:
swift post -m 'web-listings: true' static
Set custom error pages
swift post -m 'web-error:error.html' static
When a file is requested that does not exist, then a 404 error code is returned. The command above will make sure that a file 404error.html is returned when it is present. You can do this for all HTTP return codes.
Enable a custom listings style sheet
swift post -m 'web-listings-css:style.css' static
Example
Suppose we have the following html files index.html which links to page.html both shown below. The page page.html displays the image surf.png.
<!-- index.html --> <html> <h1> See the web page <a href="page.html">here</a>. </h1> </html>
<!-- page.html --> <html> <img src="surf.png"/> </html>
This web site is uploaded as follows:
$ swift upload static index.html page.html $ swift upload static page.html surf.png $ swift upload static surf.png surf.png
Determine your storage URL:
$ swift stat | grep "Account:" Account: AUTH_a3f5d7b9c1e2a4d7f6e8b9c3a0d5f1c8
Your storage URL is:
https://objectstore.surf.nl/swift/v1/AUTH_a3f5d7b9c1e2a4d7f6e8b9c3a0d5f1c8
Now we can view the website on: https://objectstore.surf.nl/swift/v1/AUTH_a3f5d7b9c1e2a4d7f6e8b9c3a0d5f1c8/static/
Suppose we create a custom 404error.html file which looks as follows:
<html> <h1> This page is nowhere to be found </h1> </html>
We upload this file:
swift upload static 404error.html
Then we see this errror page if we request a file that does not exist.