I want to upload the large video with chunk functions.
kindly let me how to do.
I have already uploaded the video by chunk functions.
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)