To communicate between your website and your Cloud Files account, create a form using the following format in your website:
Example 6.8. Layout of Web Form
<form action="<CF-url>" method="POST" enctype="multipart/form-data">
<input type="hidden" name="redirect" value="<redirect-url>" />
<input type="hidden" name="max_file_size" value="<bytes>" />
<input type="hidden" name="max_file_count" value="<count>" />
<input type="hidden" name="expires" value="<unix-timestamp>" />
<input type="hidden" name="signature" value="<hmac>" />
<input type="file" name="file1" /><br />
<input type="submit" />
</form>
Required: Form action is the Cloud Files URL (CF-url) to the destination where
files will be uploaded. For instance,
https://storage.clouddrive.com/v1/CF_xer7_34/container. The name of each
uploaded object will have the <CF-url> appended to the front of it.
Your users upload directly to root of the container.
You may also include a prefix to separate uploads, such as assigning
each user a certain prefix:
https://storage.clouddrive.com/v1/CF_xer7_34/container/user_prefix.
Required: The form method must be
"POST" and the enctype must be set as
“multipart/form-data”.
Optional: The redirect attribute
is the URL of the page that displays on your website
after the form processes. The URL will have status and message query
parameters added to it, indicating the HTTP status code for the upload
(2xx is success) and a possible message for further information if there
is an error, such as “max_file_size exceeded”.
Required: The
max_file_size attribute must be included and
indicates the largest single file upload allowed, in bytes.
Although you may limit the size of the individual file
uploaded to your Cloud Files account here, the max_file_size
may not exceed 5 GB.
Required: The max_file_count attribute indicates the maximum number of
files that can be uploaded with the form.
Required: The expires attribute is the Unix timestamp when the form is
invalidated. This gives your website users a limited time to have the
form open. Time must be in Unix epoch format.
Required: The signature attribute is the HMAC-SHA1 signature of the form.
Here is sample code for computing the signature in Python:
Example 6.9. Generate Signature for Form Post
import hmac
from hashlib import sha1
from time import time
path = '/v1/account/container/object_prefix'
redirect = 'https://myserver.com/some-page'
max_file_size = 104857600
max_file_count = 10
expires = int(time() + 600)
key = 'mykey'
hmac_body = '%s\n%s\n%s\n%s\n%s' % (path, redirect,
max_file_size, max_file_count, expires)
signature = hmac.new(key, hmac_body, sha1).hexdigest()
Be certain to use the full path in your Cloud Files account, from the /v1/ onward.
Key is the value of the X-Account-Meta-Temp-URL-Key
header set for the account.
The max_file_count used in generating the signature must be the same as
that in the web form.
Required: The type="file" field
defines the form file field.
At least one entry is required to allow your users to select and upload
a file, but additional fields may be added for multiple files. The number
of entries should not, however, exceed the max_file_count.
Each type="file" field must have a different name.
Note that the type="file" field(s) must be at the end of the form code
in order for Cloud Files to process the uploads properly.

