Will there be allot of file downloads?

If there will be a big load on the site from file downloads,
especially big files. Then it's not smart to handle it in cakephp.
Especially if you want to support download accellerators/resume
support

On every request(someone that uses a download accelerator and makes 10
requests), the cakephp framework is loaded.
This is accually not needed, because it's a plain file download.
Even if you want to check a couple of things in the database, it's
better to do it manually.

This ofcouse depends on the situation you're in.
In my case, using cakephp this way would crash my server within 5
minutes(if not faster)

You can find the code I use here:

http://pastebin.com/f179e1e49

I've been using it for several years and transfer 15 to 20tb per month
using that piece of code.


/Crazy

On Jul 24, 9:58 am, Vijay Kumbhar <k.vidn...@gmail.com> wrote:
> Yeah...
>
> Thanks rufus it works .........
>
> only i changed this line,
>
> header('Content-Type: application/octet-stream'); to
>
> header("Content-Type: ".$result['Application']['resume'])."");
>
> that is the content type of the uploaded file coming from my database.
>
> Thanks again...............
>
>
>
> On Fri, Jul 24, 2009 at 12:53 PM, Rufus <rufusp...@gmail.com> wrote:
>
> > Here is my code:
>
> > pdfDir is defined constant fyi
>
> >        function download($id = null) {
>
> >                if (!$id && empty($this->data)) {
> >                        $this->Session->setFlash(__('Invalid Invoice',
> > true));
> >                        $this->redirect(array('action'=>'index'));
> >                }
>
> >                Configure::write('debug', 0);
> >                $file = $this->Invoice->findById($id);
> >    if (file_exists(pdfDir.$file['Invoice']['file_name'])) {
> >        header('Content-Description: File Transfer');
> >        header('Content-Type: application/octet-stream');
> >        header('Content-Disposition: attachment; filename='.basename
> > (pdfDir.$file['Invoice']['file_name']));
> >        header('Content-Transfer-Encoding: binary');
> >        header('Expires: 0');
> >        header('Cache-Control: must-revalidate, post-check=0, pre-
> > check=0');
> >        header('Pragma: public');
> >        header('Content-Length: ' . filesize(pdfDir.$file['Invoice']
> > ['file_name']));
> >        ob_clean();
> >        flush();
> >        readfile(pdfDir.$file['Invoice']['file_name']);
> >        exit;
> >    } else {
> >                        $this->Session->setFlash(__('File Does Not Exist',
> > true));
> >                        $this->redirect(array('action'=>'index'));
> >     }
>
> >        }
>
> > On Jul 24, 12:44 am, Vijay <k.vidn...@gmail.com> wrote:
> > > Hello All,
>
> > > I uploads the files to webroot/uploads folder from the file uploading
> > > component.
>
> > > Now I am trying to download that file from webroot/uploads folder but
> > > it is giving me 0 byte file.
>
> > > Code is as follows,
>
> > > function admin_download($id)
> > >     {
> > >         $this->adminchecksession();
> > >             // you'll want to check the login status here ...
>
> > >             $result = $this->Application->findById($id);
>
> > >             Configure::write('debug', 0);
> > >             $this->view = 'Media';
>
> > >             /* MediaView is really irritating
> > >              */
> > >             //$name = $result['Application']['resume'];
>
> > >             $ext = explode("." ,$result['Application']['resume']);
>
> > >             $params = array(
> > >                     'name' => $ext[0],
> > >                     'download' => true,
> > >                     'extension' => $ext[1],
> > >                     'path' => APP."webroot/uploads".DS,
> > >                     'mimeType' => array($result['Application']
> > > ['type'])
> > >             );
>
> > >             $this->set($params);
>
> > >     }
>
> > > Please help me on this.
>
> --
> Thanks & Regards,
> Vijayk.
> Co-founder (www.weboniselab.com)
>
> "You Bring the Dreams, We'll Bring the Means"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to