Codulle - L'explorateur de code sources
Informations fichier
Nom du fichier : -
Taille du fichier : -
Language : -
OMzip
|
When it comes to sending several files to a website visitor's disk, we all come to the same solution : zip the files, and send the zip.
Yes, but ...
- many users don't actually know what to do with an archive : you lose half of the visitors
- the zipping process with many large files is extremely resource-consuming (disk + CPU + process).
The main goal of my on-the-fly zipper is there : it is able to create a zip structure and to send it to the visitor at the same time, with the ability to predict the final file size so that the user can have a progress indication of the download !
More precisely :
- it computes the zip file exact size considering the input files size and the structure. The zip size is sent as HTTP header to the visitor.
- it creates a zip structure in the output buffer (the buffer that is sent to the visitor by the web server, progressively when it is filled)
- it creates the directory entries in the structure
- it adds the files entries in the structure with "no-compress" option, to declare that the file is actually uncompressed in the zip : this way, no heavy processing is required on the server, and the file has the same size as when it is compressed with most heavy files (photos, videos, music, programs)
- it pushes the file itself in the output buffer
- it computes the file CRC using the built-in most-efficient function by hashing the file in small pieces (which requires a CRC32 hack!)
- it loops for each file, and then closes the structure. Job Done.
- Its only restriction is the computing time allowed by the server, that is sometimes limited to 30s.
The software can run on any PHP server. The visitor just runs a usual browser : he does not see any difference with a standard zip process.
Want to see it in action? This site integrates this system to send you archives of the projects : just click any of the download icons on your left.
My software has been used since 2005 by my private website visitors.
To get a licence, please contact me at matheret@free.fr
O. Matheret
|