Forms

S3UploadForm

class s3upload.forms.S3UploadForm(success_action_redirect=None, **kwargs)

Bases: s3upload.forms.ContentTypePrefixMixin, s3upload.forms.KeyPrefixMixin, s3upload.forms.StorageMixin, django.forms.forms.Form

Form for uploading a file directly to an S3 bucket.

__init__(success_action_redirect=None, **kwargs)
_base64_encode(string)
add_prefix(field_name)
base_fields = OrderedDict([('access_key', <django.forms.fields.CharField object at 0x7f03ae4b56d0>), ('acl', <django.forms.fields.CharField object at 0x7f03ae4b5810>), ('cache_control', <django.forms.fields.CharField object at 0x7f03ae4b5890>), ('content_type', <django.forms.fields.CharField object at 0x7f03ae4b5910>), ('key', <django.forms.fields.CharField object at 0x7f03ae4b5990>), ('policy', <django.forms.fields.CharField object at 0x7f03ae4b5a10>), ('success_action_redirect', <django.forms.fields.CharField object at 0x7f03ae4b5a90>), ('success_action_status', <django.forms.fields.CharField object at 0x7f03ae4b5b10>), ('signature', <django.forms.fields.CharField object at 0x7f03ae4b5b90>), ('file', <django.forms.fields.FileField object at 0x7f03ae4b5bd0>)])
declared_fields = OrderedDict([('access_key', <django.forms.fields.CharField object at 0x7f03ae4b56d0>), ('acl', <django.forms.fields.CharField object at 0x7f03ae4b5810>), ('cache_control', <django.forms.fields.CharField object at 0x7f03ae4b5890>), ('content_type', <django.forms.fields.CharField object at 0x7f03ae4b5910>), ('key', <django.forms.fields.CharField object at 0x7f03ae4b5990>), ('policy', <django.forms.fields.CharField object at 0x7f03ae4b5a10>), ('success_action_redirect', <django.forms.fields.CharField object at 0x7f03ae4b5a90>), ('success_action_status', <django.forms.fields.CharField object at 0x7f03ae4b5b10>), ('signature', <django.forms.fields.CharField object at 0x7f03ae4b5b90>), ('file', <django.forms.fields.FileField object at 0x7f03ae4b5bd0>)])
expiration_timedelta = datetime.timedelta(0, 1800)
field_name_overrides = {u'access_key': u'AWSAccessKeyId', u'cache_control': u'Cache-Control', u'content_type': u'Content-Type'}
get_access_key()
get_acl()

Return the acl to be set on the uploaded file.

By default this sets a ‘private’ acl, and should probably be kept that way. You can set the final acl when the upload is validated/processed.

get_action()
get_cache_control()
get_conditions()
get_connection()
get_expiration_time(refresh=False)
get_key()
get_policy()
get_secret_key()
get_signature()
get_success_action_redirect()
get_success_action_status_code()
media
success_action_status_code = 204

DropzoneS3UploadForm

class s3upload.forms.DropzoneS3UploadForm(success_action_redirect=None, **kwargs)

Bases: s3upload.forms.S3UploadForm

Form for uploading a file directly to an S3 bucket using dropzone.js.

__init__(success_action_redirect=None, **kwargs)
class Media

Bases: object

css = {u'all': [u's3upload/css/dropzone.css']}
js = [u's3upload/dropzone.js', u's3upload/dropzone-options.js']
DropzoneS3UploadForm.base_fields = OrderedDict([('access_key', <django.forms.fields.CharField object at 0x7f03ae4b56d0>), ('acl', <django.forms.fields.CharField object at 0x7f03ae4b5810>), ('cache_control', <django.forms.fields.CharField object at 0x7f03ae4b5890>), ('content_type', <django.forms.fields.CharField object at 0x7f03ae4b5910>), ('key', <django.forms.fields.CharField object at 0x7f03ae4b5990>), ('policy', <django.forms.fields.CharField object at 0x7f03ae4b5a10>), ('success_action_redirect', <django.forms.fields.CharField object at 0x7f03ae4b5a90>), ('success_action_status', <django.forms.fields.CharField object at 0x7f03ae4b5b10>), ('signature', <django.forms.fields.CharField object at 0x7f03ae4b5b90>), ('file', <django.forms.fields.FileField object at 0x7f03ae4b5bd0>)])
DropzoneS3UploadForm.declared_fields = OrderedDict([('access_key', <django.forms.fields.CharField object at 0x7f03ae4b56d0>), ('acl', <django.forms.fields.CharField object at 0x7f03ae4b5810>), ('cache_control', <django.forms.fields.CharField object at 0x7f03ae4b5890>), ('content_type', <django.forms.fields.CharField object at 0x7f03ae4b5910>), ('key', <django.forms.fields.CharField object at 0x7f03ae4b5990>), ('policy', <django.forms.fields.CharField object at 0x7f03ae4b5a10>), ('success_action_redirect', <django.forms.fields.CharField object at 0x7f03ae4b5a90>), ('success_action_status', <django.forms.fields.CharField object at 0x7f03ae4b5b10>), ('signature', <django.forms.fields.CharField object at 0x7f03ae4b5b90>), ('file', <django.forms.fields.FileField object at 0x7f03ae4b5bd0>)])
DropzoneS3UploadForm.media
DropzoneS3UploadForm.success_action_status_code = 201

ValidateS3UploadForm

class s3upload.forms.ValidateS3UploadForm(process_to=None, processed_key_generator=None, **kwargs)

Bases: s3upload.forms.ContentTypePrefixMixin, s3upload.forms.KeyPrefixMixin, s3upload.forms.StorageMixin, django.forms.forms.Form

Form used to validate returned data from S3.

Not for use in templates - we’re only processing/validating the provided data.

__init__(process_to=None, processed_key_generator=None, **kwargs)
static _generate_processed_key_name(process_to, upload_name)

Returns a key name to use after processing based on timestamp and upload key name.

base_fields = OrderedDict([('bucket_name', <django.forms.fields.CharField object at 0x7f03ae4b5f10>), ('etag', <django.forms.fields.CharField object at 0x7f03ae4b5f90>), ('key_name', <django.forms.fields.CharField object at 0x7f03ae4c1050>)])
clean()
clean_bucket_name()

Validates that the bucket name in the provided data matches the bucket name from the storage backend.

clean_key_name()

Validates that the key in the provided data starts with the required prefix, and that it exists in the bucket.

declared_fields = OrderedDict([('bucket_name', <django.forms.fields.CharField object at 0x7f03ae4b5f10>), ('etag', <django.forms.fields.CharField object at 0x7f03ae4b5f90>), ('key_name', <django.forms.fields.CharField object at 0x7f03ae4c1050>)])
get_processed_acl()

Return the acl to be set on the processed file.

get_processed_key_name()

Return the full path to use for the processed file.

get_processed_path()

Returns the processed file path from the storage backend.

Returns:File path from the storage backend.
Return type:unicode
get_upload_content_type()

Determine the actual content type of the upload.

get_upload_key()

Get the Key from the S3 bucket for the uploaded file.

Returns:Key (object) of the uploaded file.
Return type:boto.s3.key.Key
get_upload_key_metadata()

Generate metadata dictionary from a bucket key.

get_upload_path()

Returns the uploaded file path from the storage backend.

Returns:File path from the storage backend.
Return type:unicode
media
process_to = u'processed/'
process_upload(set_content_type=True)

Process the uploaded file.