Liberty -  Liberty -  Liberty -  Liberty -  Liberty -  Liberty -  Liberty -  Liberty - 

 Form post

Middleware that enables you to upload objects to a cluster by using an HTML form POST.

The format of the form is:

<![CDATA[
<form action="<swift-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="hidden" name="x_delete_at" value="<unix-timestamp>"/>
  <input type="hidden" name="x_delete_after" value="<seconds>"/>
  <input type="file" name="file1" /><br />
  <input type="submit" />
</form>]]>

In the form:

  • action="<swift-url>"

    The URL to the Object Storage destination, such as https://swift-cluster.example.com/v1/AUTH_account/container/object_prefix.

    The name of each uploaded file is appended to the specified swift-url. So, you can upload directly to the root of container with a URL like https://swift-cluster.example.com/v1/AUTH_account/container/.

    Optionally, you can include an object prefix to separate different users' uploads, such as https://swift-cluster.example.com/v1/AUTH_account/container/object_prefix.

  • method="POST"

    The form method must be POST.

  • enctype="multipart/form-data

    The enctype must be set to multipart/form-data.

  • name="redirect"

    The URL to which to redirect the browser after the upload completes. The URL has status and message query parameters added to it that indicate the HTTP status code for the upload and, optionally, additional error information. The 2nn status code indicates success. If an error occurs, the URL might include error information, such as "max_file_size exceeded".

  • name="max_file_size"

    Required. The maximum number of bytes that can be uploaded in a single file upload.

  • name="max_file_count"

    Required. The maximum number of files that can be uploaded with the form.

  • name="expires"

    The expiration date and time for the form in UNIX Epoch time stamp format. After this date and time, the form is no longer valid.

    For example, 1440619048 is equivalent to Mon, Wed, 26 Aug 2015 19:57:28 GMT.

  • name="signature"

    The HMAC-SHA1 signature of the form. This sample Python code shows how to compute the signature:

    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()

    The key is the value of the X-Account-Meta-Temp-URL-Key header on the account.

    Use the full path from the /v1/ value and onward.

    During testing, you can use the swift-form-signature command-line tool to compute the expires and signature values.

  • name="x_delete_at"

    The date and time in UNIX Epoch time stamp format when the object will be removed.

    For example, 1440619048 is equivalent to Mon, Wed, 26 Aug 2015 19:57:28 GMT.

    This attribute enables you to specify the X-Delete- At header value in the form POST.

  • name="x_delete_after"

    The number of seconds after which the object is removed. Internally, the Object Storage system stores this value in the X-Delete-At metadata item. This attribute enables you to specify the X-Delete-After header value in the form POST.

  • type="file" name="filexx"

    Optional. One or more files to upload. Must appear after the other attributes to be processed correctly. If attributes come after the file attribute, they are not sent with the sub- request because on the server side, all attributes in the file cannot be parsed unless the whole file is read into memory and the server does not have enough memory to service these requests. So, attributes that follow the file attribute are ignored.

Table 11.88. Description of configuration options for [filter-formpost] in proxy-server.conf
Configuration option = Default value Description
use = egg:swift#formpost Entry point of paste.deploy in the server

Questions? Discuss on ask.openstack.org
Found an error? Report a bug against this page

loading table of contents...