def get_download_background_image_thumbnail(self, obj): if not obj.background_image_thumbnail: return None request = get_current_request() path = reverse('kanbanboard-background-image-thumbnail.png', kwargs={'pk': obj.pk}) return build_expiring_jwt_url(request, path)
def build_download_url_with_token(picture, reverse_url_name): request = get_current_request() if picture.uploaded_picture_entry is None: raise IntegrityError("uploaded_picture_entry is not referenced") path = reverse(reverse_url_name, kwargs={'pk': picture.uploaded_picture_entry.pk}) return build_expiring_jwt_url(request, path)
def get_download_directory(self, obj): """ Builds a string for downloading the directory with a jwt token """ request = get_current_request() path = reverse('drive-sub_directories-download', kwargs={ 'drive_pk': obj.drive.pk, 'pk': obj.pk }) return build_expiring_jwt_url(request, path)
def get_export_link(self, request, pk=None): """ Generates a link with a JWT for the export endpoint. This is necessary so browsers can access the exported content without sending authorization headers. """ # try to get the object to force a permission check self.get_object() path = request.path.replace('get_export_link', 'export') return Response({ 'url': build_expiring_jwt_url(request, path) })
def build_download_url_with_token(plugin, reverse_url_name): request = get_current_request() path = reverse(reverse_url_name, kwargs={'pk': plugin.pk}) return build_expiring_jwt_url(request, path)