diff --git a/django_etebase/serializers.py b/django_etebase/serializers.py index c194fdd..9ca33b1 100644 --- a/django_etebase/serializers.py +++ b/django_etebase/serializers.py @@ -83,8 +83,7 @@ class CollectionContentField(BinaryBase64Field): class ChunksField(serializers.RelatedField): def to_representation(self, obj): obj = obj.chunk - inline = self.context.get('inline', False) - if inline: + if self.context.get('prefetch'): with open(obj.chunkFile.path, 'rb') as f: return (obj.uid, b64encode(f.read())) else: diff --git a/django_etebase/views.py b/django_etebase/views.py index 0606e5b..64acb18 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -167,8 +167,8 @@ class CollectionViewSet(BaseViewSet): def get_serializer_context(self): context = super().get_serializer_context() - inline = 'inline' in self.request.query_params - context.update({'request': self.request, 'inline': inline}) + prefetch = self.request.query_params.get('prefetch', True) + context.update({'request': self.request, 'prefetch': prefetch}) return context def destroy(self, request, uid=None): @@ -239,8 +239,8 @@ class CollectionItemViewSet(BaseViewSet): def get_serializer_context(self): context = super().get_serializer_context() - inline = 'inline' in self.request.query_params - context.update({'request': self.request, 'inline': inline}) + prefetch = self.request.query_params.get('prefetch', True) + context.update({'request': self.request, 'prefetch': prefetch}) return context def create(self, request, collection_uid=None):