api.v1.views.AttachmentViewSet module

Module with the AttachmentViewSet viewset.

class api.v1.views.AttachmentViewSet.AttachmentViewSet(**kwargs)[source]

Bases: ReadOnlyModelViewSet, DestroyModelMixin, ToggleFavoriteMixin

Viewset for the core.models.Attachment.

Provides every read-only and a destroy action.

BASENAME = 'attachment'
serializer_class

alias of BaseAttachmentSerializer

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]
filterset_class

alias of AttachmentFilterSet

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]
ordering_fields: Final[list[str]] = ['file_name', 'datasize', 'email__datetime', 'is_favorite', 'created', 'updated']
ordering: Final[list[str]] = ['id']
get_queryset()[source]

Filters the data for entries connected to the request user.

Return type:

QuerySet

Returns:

The attachment entries matching the request user.

URL_PATH_DOWNLOAD = 'download'
URL_NAME_DOWNLOAD = 'download'
download(request, pk=None)[source]

Action method downloading the attachment.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the attachment to download. Defaults to None.

Raises:

Http404 – If the filepath is not in the database or it doesn’t exist.

Return type:

FileResponse

Returns:

A fileresponse containing the requested file.

URL_PATH_DOWNLOAD_BATCH = 'download'
URL_NAME_DOWNLOAD_BATCH = 'download-batch'
download_batch(request)[source]

Action method downloading a batch of attachments.

Parameters:

request (Request) – The request triggering the action.

Raises:
  • Http404 – If no downloadable attachment has been requested.

  • ValidationError – If id param is missing or in invalid format.

Return type:

Response | FileResponse

Returns:

A fileresponse containing the requested file.

URL_PATH_THUMBNAIL = 'thumbnail'
URL_NAME_THUMBNAIL = 'thumbnail'
download_thumbnail(request, pk=None)[source]

Action method downloading the attachment thumbnail.

Returns the same filedata as ‘download’, but as inline.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the attachment to download. Defaults to None.

Raises:

Http404 – If the filepath is not in the database or it doesn’t exist.

Return type:

FileResponse

Returns:

A fileresponse containing the requested file.

URL_PATH_SHARE_TO_PAPERLESS = 'share/paperless'
URL_NAME_SHARE_TO_PAPERLESS = 'share-to-paperless'
share_to_paperless(request, pk=None)[source]

Action method sending the attachment to the users Paperless server.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the attachment to upload. Defaults to None.

Raises:

Http404 – If the filepath is not in the database or it doesn’t exist.

Return type:

Response

Returns:

A fileresponse containing the requested file.

URL_PATH_SHARE_TO_IMMICH = 'share/immich'
URL_NAME_SHARE_TO_IMMICH = 'share-to-immich'
share_to_immich(request, pk=None)[source]

Action method sending the attachment to the users Immich server.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the attachment to upload. Defaults to None.

Raises:

Http404 – If the filepath is not in the database or it doesn’t exist.

Return type:

Response

Returns:

A fileresponse containing the requested file.

basename = None
description = None
destroy(request, *args, **kwargs)
detail = None
list(request, *args, **kwargs)
name = None
retrieve(request, *args, **kwargs)
suffix = None