>
> On a "back-end" server, I have an application responsible to manage large
> files (some Gigabytes).
> On a "front-end" server, I want to allow the end-users to download files
> stored on the back-end, but without making the back-end server directly
> accessible from all Internet.
> On the front-end server.
>
> On the front-end, I tried the following piece of code :
>
> use Mojolicious::Lite;
> use Mojo::UserAgent;
>
>
> get '/dl' => sub {
> my $c = shift;
> my $ua = Mojo::UserAgent->new;
> my $tx = $ua->build_tx(GET => 'https://BACKEND/my_file.zip');
> $tx->res->content->unsubscribe('read')->on(read => sub {
> my ($content, $bytes) = @_;
> $c->write($bytes);
> });
> $tx = $ua->start($tx);
> };
>
> app->start;
>
Yea, something like that should work. We've been meaning to add a more user
friendly API, but never got around to it. Right now i'm afraid it's quite
tricky to get
right, but possible.
>
> The problem is that the whole file seems to be downloaded and stored in
> memory, before being sent. I would like to be able to write a chunk of data
> just after receiving it from the back-end server, without waiting the end
> of the whole file download. I thought that redefining the "read" event
> would do the job but something is probably missing.
>
That doesn't sound right. If you unsubscribed from the read event there is
nothing
left to store the message content anywhere.
--
sebastian
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.