[Dancer-users] sending file fails

Puneet Kishor punk.kish at gmail.com
Tue Jan 4 03:01:43 CET 2011


 solved!


I can't give a full, absolute path name to the file when using `send_file`. I *have* to give a path relative to the 'public' directory. Changing the path to relative to 'public' sends the file alright.


Could this *please* be listed in *bold* in the documentation for `send_file`?


Many thanks,


-- 
Puneet Kishor
Sent with Sparrow

On Monday, January 3, 2011 at 7:09 PM, Puneet Kishor wrote:

> This is driving me nuts, so I would appreciate any advice. Perhaps it is just a silly oversight on my part.
> 
> 
> punkish at Lucknow ~/Sites/carbonapp/public/images/models/2bau/years/8$pwd
> /Users/punkish/Sites/carbonapp/public/images/models/2bau/years/8
> punkish at Lucknow ~/Sites/carbonapp/public/images/models/2bau/years/8$ls 2*
> 2010_nep.gif
> punkish at Lucknow ~/Sites/carbonapp/public/images/models/2bau/years/8$
> 
> 
> So, as you can see, the following file exists
> 
> 
> /Users/punkish/Sites/carbonapp/public/images/models/2bau/years/8/2010_nep.gif
> 
> 
> My route is
> 
> 
> get '/:model_id/year/:year/zoom/:zoom/:output' => sub {
> my $model_id = params->{model_id};
> my $year = params->{year};
> my $zoom = params->{zoom};
> my $output = params->{output};
> 
> 
> # get model_file based on model_id
> 
> my $dir = config->{'app_dir'} . '/' . config->{'img_dir'} . "/$model_file/years/$zoom";
> my $img = $year . '_' . $output . '.gif';
> 
> debug("sending '$dir/$img'");
> send_file("$dir/$img");
> };
> 
> 
> 
> My development.log shows
> 
> 
> 
> 
> [37838] debug @0.008607> [hit #1] sending '/Users/punkish/Sites/carbonapp/public/images/models/2bau/years/8/2010_nep.gif' in /Users/punkish/Sites/carbonapp/lib/carbonapp/models.pm l. 106
> 
> 
> and yet, I get the following error in my browser
> 
> 
> {"error":"No such file: `/Users/punkish/Sites/carbonapp/public/images/models/2bau/years/8/2010_nep.gif'"}
> 
> 
> Please point me to my stupid ways.
> 
> 
> 
> -- 
> Puneet Kishor
> Sent with Sparrow
> 
> 
> 
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110103/b3c5bb35/attachment-0001.htm>


More information about the Dancer-users mailing list