I'm confident people will correct my mistakes... A file is transferred from a web browser to a web server by breaking it up into packets at the network layer. Each packet is part of the file and you need the complete set of packets to recreate the whole request, and thus the whole file. Assuming you're using the default backend, as each packet arrives it is placed into memory whilst we wait for the rest of the packets to arrive. This the uploading process.
When all the packets of the HttpRequest have arrived and are in memory. Then your code is executed and you can elect to do whatever you like with the data sitting in memory, like write it to disk. That would be the saving part. But that was the default behaviour. If you want something different to happen, you can use a different backend, or even build your own backend. For example you won't have to look too far before finding a backend which writes the "chunks" of the data directly to disk as they arrive, rather than waiting for them to be marshalled in memory. Whether you get preferred results by writing to memory or to disk is entirely subjective upon your application and hardware. If you expect a lot of people to be uploading a lot of very large files simultaneously, and your server has very little memory, then you might find writing directly to disk is preferable; but the default is the default because that works best for most subjects. On Dec 14, 5:55 am, sjtirtha <sjtir...@gmail.com> wrote: > Hi, > > can somebody explain me how file upload works in Django? > I read this > documentation:http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ > > And there is this part: > ################################################################################################################################################################### > Where uploaded data is > stored¶<http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#where-...> > > Before you save uploaded files, the data needs to be stored somewhere. > > By default, if an uploaded file is smaller than 2.5 megabytes, Django will > hold the entire contents of the upload in memory. This means that saving the > file involves only a read from memory and a write to disk and thus is very > fast. > > ################################################################################################################################################################### > > What does it mean by "saving the file involves only read from memory and a > write to disk..."? > I though uploading and saving a file are one process. When I upload a file > by submiting my form it means it will also save the file somewhere. > > But what I understand from the documentation is uploading and saving are two > different processes. How can I trigger the saving then? > > Regards, > > Steve -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.