[dancer-users] Dancer2 before_file_render hook

Alex Mestiashvili mailatgoogl at gmail.com
Sun Sep 27 20:03:00 BST 2015


Thank you for the hint, I think I found this advent:
http://advent.perldancer.org/2014/6 .

Can I use send_file together with a template ? Let's say I want to render
html with an image,
but I want to make the image available only if logged_in_user();
If it doesn't work with the send_file, the only way I see is to create a
random,
temporary symlinks in public pointing to the "not public" files which will
be valid during
the session and removed after the session is destroyed.
And use these temporary locations to render the protected images the usual
way.

Any other ideas ?

Thank you,
Alex

On Sun, Sep 27, 2015 at 6:17 PM, Andrew Beverley <andy at andybev.com> wrote:

> On Sun, 2015-09-27 at 18:06 +0200, Alex Mestiashvili wrote:
> > Is there a way to protect a file in the public directory with Dancer2?
>
> I think the answer is probably "don't put it in the public area".
>
> If it's not for public consumption, I suggest you use send_file in a route
> instead.
>
> > In Dancer I was using before_file_render hook to achieve that.
> > before_file_render is still present in Dancer2::Handler::File, but It
> > doesn't work out of box for me.
>
> Because it is assumed that anything in the public area is exactly that, the
> files are sent as quickly as possible, without wasting time in hooks etc.
>
> I think there was some info on these changes in the Perl Advent Calendar.
>
> Andy
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150927/696a21eb/attachment.html>


More information about the dancer-users mailing list