Tuesday, September 26, 2017

Re: POST method on localhost

Hi!

Yes that is realistic in the sense that it takes a couple of seconds to upload a 1GB file to localhost. It should take a small amount of time, because it is just copying the file (through django) to the directory you specified.

However uploading a 1 GB file to a web server on the Internet isn't feasible. It would probably take to long to upload and the connection would time out - unless you do a bit of magic on the connections. 

So, my question to you is what are you trying to accomplish? What is the purpose of your test?

Regards,

Andréas

2017-09-25 22:42 GMT+02:00 Allan <allaneivazian1@gmail.com>:
I've created a simple form for data upload.  I'm testing it through localhost and was wondering if this is realistic.  Web development is a new area for me so bare with me please if this is a laughable question.  I uploaded a 1GB file and it was uploaded and moved to a folder in my project in a matter of a few seconds.

def simple_upload(request):
   
if request.method =='POST' and request.FILES['myfile']:
        myfile
= request.FILES['myfile']
        fs
= FileSystemStorage()
        filename
= fs.save(myfile.name, myfile)
        uploaded_file_url
= fs.url(filename)
       
return render(request, 'simple_upload.html', {
           
'uploaded_file_url': uploaded_file_url
   
})

   
return render(request, 'simple_upload.html')

{% load static %}

{% block content %}
 
<form method="post" enctype="multipart/form-data">
   
{% csrf_token %}
   
<input type="file" name="myfile">
   
<button type="submit">Upload</button>
  </
form>

 
{% if uploaded_file_url %}
   
<p>File uploaded at: <a href="{{ uploaded_file_url }}">{{ uploaded_file_url }}</a></p>
 
{% endif %}

 
<p><a href="{% url 'dashboard' %}">Return to home</a></p>
{% endblock %}

Thanks!

--
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/bf2476d2-8470-4c91-8590-99ecc4f477de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAK4qSCfsUgR91_9dKgoW%2B8Lz_VvyhzdJ%3DXkTqOXyUfiZXyx7uA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment