URLs

class anchor.services.urls.BaseURLGenerator(backend: str = 'default')

Generates (signed) URLs for blobs.

URLGenerators are a workaround against the limitations of Django’s Storage interface, which doesn’t support passing parameters for URL generation. These allow us to set parameters on URLs such as the content disposition which are necessary to ensure external backends like S3 can serve blobs securely.

url(key: str, expires_in: timedelta = None, mime_type: str = None, disposition: str = 'inline', filename: str = None)

Generate a signed URL for the given storage key.

class anchor.services.urls.FileSystemURLGenerator(backend: str = 'default')

Generate signed and expiring URLs for files stored in file-system storage backends.

This generator exists so that we can have more control over how files stored via Django’s default FileSystemBackend are served by making requests go through our file system view.

url(name: str, expires_in: timedelta = datetime.timedelta(seconds=3600), filename: str = None, mime_type: str = None, disposition: str = None) str

Generate a signed URL for the given storage key.

class anchor.services.urls.S3URLGenerator(backend: str = 'default')

URL Generator for use with the S3Backend from the django-storages package.

url(key: str, expires_in: timedelta = None, filename: str = None, mime_type: str = None, disposition: str = None) str

Generate a signed URL for the given storage key.

anchor.services.urls.get_for_backend(backend: str) BaseURLGenerator

Given a Django storage backend name, return a URLGenerator instance that can work with it.

If no suitable generator is found, this function will return the BaseURLGenerator which delegates URL generation to the storage backend.