Monday, June 25, 2018

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

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.

On Monday, June 25, 2018 at 7:43:29 AM UTC-4, Pravin Yadav wrote:
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)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b88ade1e-4420-4150-99b9-c80e8e8192e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment