Uploaded file performance

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Uploaded file performance

kern zhou

I am using the django to handle the file upload.
In the view implementation, I am trying to write the uploaded file to disk, but it causes bad performance because writing the uploaded file to disk spend lots of time.
Is any better solution to handle the file upload´╝č Maybe create a detach thread to handle the file writing

The below is the simplified view implementation:

def upload_file(request): 
  if request.method == 'POST': 
           form = UploadFileForm(request.POST, request.FILES) 
            if form.is_valid():                                      
                  with open('some/file/name.txt', 'wb+') as destination: 
                           for chunk in f.chunks(): 
            return HttpResponseRedirect('/success/url/') 
          form = UploadFileForm() 
          return render(request, 'upload.html', {'form': form})  

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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e527a0a7-2e8e-4225-b212-fd6767ece12cn%40googlegroups.com.