Jump to >


An avatar service for providing uploaded images.

class FileUploadServiceForm(*args, **kwargs)[source]

Bases: djblets.avatars.forms.AvatarServiceConfigForm

The FileUploadService configuration form.

avatar_service_id = u'file-upload'[source]
js_view_class = u'Djblets.Avatars.FileUploadSettingsFormView'[source]
template_name = u'avatars/services/file_upload_form.html'[source]
MAX_FILE_SIZE = 1048576[source]
is_multipart = True[source]

Ensure the uploaded file is an image of an appropriate size.

Returns:The uploaded file, if it is valid.
Return type:django.core.files.UploadedFile
Raises:django.core.exceptions.ValidationError – Raised if the file is too large or the incorrect MIME type.

Save the file and return the configuration.

Returns:The avatar service configuration.
Return type:dict
declared_fields = {'avatar_upload': <django.forms.fields.FileField object>, 'form_target': <django.forms.fields.CharField object>}[source]
class FileUploadService(settings_manager_class)[source]

Bases: djblets.avatars.services.base.AvatarService

An avatar service for uploaded images.

avatar_service_id = u'file-upload'[source]
name = u'File Upload'[source]

alias of FileUploadServiceForm


The storage location for uploaded avatars.

This will be prepended to the path of all uploaded files. By default, it is controlled by the UPLOADED_AVATARS_PATH setting.


Create a unique filename.

The unique filename will be the original filename suffixed with a generated UUID.

Parameters:filename (unicode) – The filename, excluding the extension.
Returns:The unique filename.
Return type:unicode
get_avatar_urls_uncached(user, size)[source]

Return the avatar URLs for the requested user.

dict: A dictionary containing the URLs of the user’s avatars at normal- and high-DPI.

Clean up the uploaded file.

This will delete the uploaded file from the storage.

Parameters:user (django.contrib.auth.models.User) – The user.

Return the ETag data for the user’s avatar.

Parameters:user (django.contrib.auth.models.User) – The user.
Returns:The uniquely identifying information for the user’s avatar.
Return type:list of unicode