Browse Source

* upgrade to mojo/8

Alex 'AdUser' Z 4 years ago
parent
commit
f63dcea1c4
  1. 2
      lib/LDV.pm
  2. 7
      lib/LDV/Filebin.pm
  3. 5
      lib/LDV/Zerobin.pm

2
lib/LDV.pm

@ -83,7 +83,7 @@ sub startup {
$fb->get ('/latest') -> to(action => 'latest')
if $conf->{show_latest};
mkdir $self->app->home->rel_dir('public/files');
mkdir $self->app->home->child('public', 'files');
$ENV{MOJO_MAX_MESSAGE_SIZE} = $conf->{file_maxsize} + 2 * 1024 * 1024; # +2Mb
}
}

7
lib/LDV/Filebin.pm

@ -67,11 +67,8 @@ sub save {
die "no file uploaded\n" unless ($upload and $upload->size > 0);
die "file too large\n" if ($upload->size > $conf->{file_maxsize});
{ # hack: don't use memory backend
my $path = POSIX::tmpnam;
$upload->move_to($path);
$upload->asset(Mojo::Asset::File->new(path => $path));
$upload->asset->cleanup(1); # rearm self-destruction
unless ($upload->asset->is_file) {
$upload->asset->to_file;
}
my $file = {

5
lib/LDV/Zerobin.pm

@ -4,7 +4,8 @@ use strict;
use warnings;
use utf8;
use POSIX qw(strftime tmpnam);
use POSIX qw(strftime);
use File::Temp qw(tempfile);
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Asset::File;
use Mojo::Util qw(b64_encode b64_decode decode encode);
@ -97,7 +98,7 @@ sub save {
die("empty paste\n") unless $paste;
} elsif ($source eq 'file') {
require File::MimeInfo::Magic;
my $tmpfile = tmpnam();
my ($fh, $tmpfile) = tempfile();
my $maxsize = $self->app->config->{zerobin}->{maxsize};
my $upload = $self->req->upload('file');
die("empty uploaded file\n")

Loading…
Cancel
Save