How to upload the large video with chunk (Django+Python)

202 views
Skip to first unread message

Pravin Yadav

unread,
Jun 25, 2018, 7:43:29 AM6/25/18
to Django users
Hello,

I want to upload the large video with chunk functions.
kindly let me how to do.


Thanks,
Pravin Yadav

I have already uploaded the video by chunk functions.
it's my views.py.

from django.http import HttpResponseRedirect
from django.shortcuts import render
from .forms import UploadFileForm

from cmspage.models import Menu
#from handle import handle_uploaded_file

def upload_file(request):
menuHeaderlist = Menu.objects.filter(status=1,menu_location='header').all()
menuFooterlist = Menu.objects.filter(status=1,menu_location='footer').all()
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
handle_uploaded_file(request.FILES['video_name'])
return HttpResponseRedirect('/uploadvideo/upload_file')
else:
form = UploadFileForm()

return render(request, 'uploadvideo/index.html', {'form': form,'menuHeaderlist':menuHeaderlist,'menuFooterlist':menuFooterlist})


def handle_uploaded_file(f):
filename = str(f)
with open('media/uploadvideo/'+filename+'', 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)

Jason

unread,
Jun 25, 2018, 8:31:13 AM6/25/18
to Django users
you should look for a javascript library to handle this client side part for you.  If you're using a cms, check to see how it handles it.

Pravin Yadav

unread,
Jun 25, 2018, 9:13:42 AM6/25/18
to django...@googlegroups.com
Hello Everyone,
Thanks in Advance
Reply all
Reply to author
Forward
0 new messages