Paste #144488

   
pasted on 11.09.2020 11:12
  • Edit to this paste
  • Print
  • Raw
  • Compare it with the parent paste
  • Look at the parent paste
  • The following pastes replied to this paste:  # 145523
  • Show paste tree
  • Compare with paste
    #  
  • Toggle line numbers
  • Syntax highlighting  
Text paste
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
after_build_tx => sub {
  my ($tx, $app) = @_;

  $tx->once('chunk'=>sub {
    my ($tx, $chunk) = @_;
    my $url = $tx->req->url->to_abs;
    my $feed = $url->path->to_route;

    return 
      unless $url->path->to_route =~ /ffmpeg/
        and $tx->req->method eq 'POST';
    $feed = $app->feeds->{$feed} = {tx=>$tx, clients=>{}};

    $tx->req->max_message_size(0);

    $tx->req->content->asset->on(upgrade => sub {
      my ($mem, $file) = @_;
      $file->handle->close;
      $file->handle(IO::File->new("> /dev/null"));
    });
    
    $tx->on('chunk'=>sub {
      my ($tx, $chunk) = @_;
      $_->tx->send({binary => $chunk})
        for (values %{$feed->{clients}});
    });
  });
},
Add Comment
Author