|
|
| Author |
Message |
|
| Guest |
Posted: Mon Aug 06, 2007 12:30 pm |
|
|
|
Guest
|
Wonder if anyone can help.
Part of my current erlyweb project needs to serve text and binary
files that have been uploaded. I have done the upload bit but am
having issues working out how to achieve the downloading/streaming. I
the usage scenario for my app, the user uploads a file to a space. the
file appears as a hyper link within that space. The user can click of
this link and the file will be delivered over http through the browser
(just like a file in apache/yaws etc..). The catch is I need to
authorise the user in the same way I do when they access the space in
the browser. At the moment I check if the user is logged in inside the
hook/1. I then check access privileges (using an internal scheme)
using the before_call/2. So the delivery of the uploaded files needs
to use the same or similar scheme. I have already seen the yaws doc
about streaming http://yaws.hyber.org/stream.yaws. This gives me some
clues although the example would be better if it actually used files
in my opinion. The difficult part is how I would use this facility in
combination with ErlyWeb and help or suggestions would be appreciated.
regards
Al
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Mon Aug 06, 2007 3:47 pm |
|
|
|
Guest
|
Actually I have just discovered Yaws authmod directive. I am going to
try to use this in the meantime.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Sun Aug 12, 2007 3:47 am |
|
|
|
Guest
|
Hi Al,
The approach I like to take for authentication is this: in hook/1,
check if the user is logged in. If he is, put this information (and
possibly the user's session data) in the Arg's 'opaque' list. E.g.
hook(A) ->
A1 = case logged_in(A) of
true ->
yaws_arg:opaque(A, [get_session_data(A), yaws_arg:opaque(A)]);
false ->
A,
....
% rest of function
Then, in the ErlyWeb controllers, you can easily check if the user is
logged in (and get his session data) by examining the Arg's opaque
field.
I personally don't like to use before_call(). I like to have a function such as
if_logged_in(A, Fun) ->
case logged_in(A) of
true ->
Fun();
false ->
{ewr, login_page}
end.
and then use it in controller functions directly (this is a matter of
preference, of course).
To use the streaming directive, simply return the 'response' tuple
from your controller function (see 'returning arbitrary yaws tuples'
in the ErlyWeb docs), e.g.
{response, [{streamcontent, "application/octet-stream", <<>>}]}.
Everything else should work identically to the Yaws docs.
Yariv
On 8/6/07, Al <al@folknology.com> wrote:
>
> Wonder if anyone can help.
>
> Part of my current erlyweb project needs to serve text and binary
> files that have been uploaded. I have done the upload bit but am
> having issues working out how to achieve the downloading/streaming. I
> the usage scenario for my app, the user uploads a file to a space. the
> file appears as a hyper link within that space. The user can click of
> this link and the file will be delivered over http through the browser
> (just like a file in apache/yaws etc..). The catch is I need to
> authorise the user in the same way I do when they access the space in
> the browser. At the moment I check if the user is logged in inside the
> hook/1. I then check access privileges (using an internal scheme)
> using the before_call/2. So the delivery of the uploaded files needs
> to use the same or similar scheme. I have already seen the yaws doc
> about streaming http://yaws.hyber.org/stream.yaws. This gives me some
> clues although the example would be better if it actually used files
> in my opinion. The difficult part is how I would use this facility in
> combination with ErlyWeb and help or suggestions would be appreciated.
>
> regards
> Al
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|