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 - . So far, best to top out containers at 1MM files. This may change in Q1-2012.
- 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
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
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.
Content-Disposition: inline; filename=file.html
File names with spaces must be wrapped in double-quotes:
Content-Disposition: inline; filename="the file name.html"