# Streaming a video from Django

**URL:** https://forum.djangoproject.com/t/streaming-a-video-from-django/17272
**Category:** Forms & APIs
**Created:** [November 25, 2022, 7:16pm UTC](https://forum.djangoproject.com/t/streaming-a-video-from-django/17272 "2022-11-25T19:16:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![samul-1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/samul-1/32/4767_2.png) [@samul-1](https://forum.djangoproject.com/u/samul-1)
#### Post date: [November 25, 2022, 7:16pm UTC](https://forum.djangoproject.com/t/streaming-a-video-from-django/17272/1 "2022-11-25T19:16:24Z")

</div>

I am developing a Django REST application that allows users to upload different types of files and view them in a Vue.js frontend without having to download them to their disk.

Just to give you an idea, think of Google Drive, which allows users to preview their files online without downloading them.

When it comes to videos, something I’d like to do is for the backend to stream the video to the frontend application, instead of the frontend downloading the whole file before being able to play it.

Right now, the view I’m using to deliver files looks like this:

```auto
@action(detail=True, methods=["get"])
def download(self, request, **kwargs):
    file = self.get_object().file # file is the name of a FileField of a model
  
    if not bool(file):
        return Response(status=status.HTTP_204_NO_CONTENT)
  
    return FileResponse(
        file,
        as_attachment=True,
        filename=os.path.split(file.name)[1],
    )

```

This downloads the whole file in one chunk before the user can use it.

Is there a way to stream the file to the user to achieve the experience I described? I have taken a look at `StreamingHttpResponse`, but I’m still unsure how I’d use it at the moment.

EDIT: after a closer inspection, I realized `FileResponse` inherits from `StreamingHttpResponse`. However, from inspecting the browswer activity it appears the file is downloaded in one go. Could it be I’m just testing with files that are too small?

---

<div class="post-metadata">

### Author: ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)
#### Post date: [November 25, 2022, 7:56pm UTC](https://forum.djangoproject.com/t/streaming-a-video-from-django/17272/2 "2022-11-25T19:56:58Z")

</div>

You don’t want to try to do this with native Django.

See the variety of other discussions on this forum as to why trying to stream media through Django is not a good idea.
