This commit is contained in:
Luc Didry 2016-06-07 00:27:08 +02:00 committed by Luc Didry
parent 9cf06931e5
commit 6f3cf342ac
1 changed files with 6 additions and 1 deletions

View File

@ -2,7 +2,7 @@
package Lufi::Controller::Files;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON qw(encode_json decode_json true false);
use Mojo::Util qw(slurp spurt encode);
use Mojo::Util qw(slurp spurt encode decode);
use LufiDB;
use Lufi::File;
use Lufi::Slice;
@ -26,6 +26,7 @@ sub upload {
my ($json) = split('XXMOJOXX', $text, 2);
$json = encode 'UTF-8', $json;
$text =~ s/^.*?XXMOJOXX/${json}XXMOJOXX/;
$json = decode_json $json;
$c->app->log->debug('Got message');
@ -179,6 +180,10 @@ sub download {
my $e = $f->slices->[$num];
my $text = slurp $e->path;
my ($json2) = split('XXMOJOXX', $text, 2);
$json2 = decode 'UTF-8', $json2;
$text =~ s/^.*?XXMOJOXX/${json2}XXMOJOXX/;
# Send the slice
$c->send($text);
} elsif (defined($json->{ended}) && $json->{ended}) {