Performance Tips
Make lots of Containers. They are cheap and assist in the replication technology. Attempt to spread your files evenly across containers, not very strict, though. Containers do not actually nest, but you can fake it: ONLY ONE CONTAINER created in this example URL - https://auth.storage.santa-clara.internapcloud.net/v1.0/f/i/l/files1.jpg. So far, best to top out containers at 1MM files. This may change in Q1-2012.
Limits
- Container names and filenames are stored as URL encoded: "my file.jpg" is longer than "my_file.jpg" because the space character becomes %20, making the full filename "my%20file.jpg" That's 13 bytes, as opposed to the 11 bytes of "my_file.jpg"
- Containers = 256 bytes max length - including URL encoding.
- Filename = 1024 bytes max length - including URL encoding.
Using with the CDN
- Set the container to be publicly accessible.
- Set it as your origin, with proper path for client and origin.
If you'd like to use the same URL to access two different containers (because you'll have more than 1MM objects in a container and need to spread them out, here are your options:
- The ideal situation from our point of view would be "multiple origins per CDN host" by including an incrementing container name in the final URL, and the origin, AND the container name.
- Second best is the mod-rewrite, because the redirects will be cached by the CDN, with little repeat traffic to the mod-rewrite host.
- Worst, of course, would be creating many CDN accounts, each one to point to a new container.
Making a Container Publicly Readable/Listable
notes
This example is with curl, but you can do it with your favorite language binding or with Cyberduck.
note especially in step 2:
-H 'X-Container-Read: .r:*'
* ".r:*" allows any IP address to access the container
How To
Get a token:
Then set the proper ACL:
Test authorized, to see headers:
Test unauthorized, to see that it's public:
Setting Content-Disposition Headers
Sometimes it is necessary that a specific file name is sent along or that a file can be saved as attachment. This can be handled by setting the content disposition header.
Example header:
Content-Disposition: inline; filename=file.html
File names with spaces must be wrapped in double-quotes:
Content-Disposition: inline; filename="the file name.html"
CURL Example
API_Key
Many times you will want to store login information for your swift account inside an application or a script. You can use your regular Ubersmith credentials for this, but that isn't ideal, as those credentials typically have more privileges than are strictly needed for your use case.
Setting up an 'API Key':
To create a separate access method for swift with reduced privileges, go to Ubersmith and create a contact record for your account. Edit the contact record and add "Login" and "Password" information. For example Login: "MyCompany_api_key" and set the password to a complex hash: "a5ddf2e5-408a-4ee3-9df1-0a1346592d3e". Now you can embed the login information associated with this new contact into your application. The contact will have full privileges inside swift to manage your data, but can't really be used to conduct other operations within Ubersmith.