From 6f3cf342acb7eeae516d675d5557ddbccbde28f0 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Tue, 7 Jun 2016 00:27:08 +0200 Subject: [PATCH] Fix #36 --- lib/Lufi/Controller/Files.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Lufi/Controller/Files.pm b/lib/Lufi/Controller/Files.pm index 8f9b408..1f845a2 100644 --- a/lib/Lufi/Controller/Files.pm +++ b/lib/Lufi/Controller/Files.pm @@ -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}) {