Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 61dca5d3

Von Tamino Steinert vor 4 Monaten hinzugefügt

  • ID 61dca5d346d9931a2665152049b9784adc83a9f0
  • Vorgänger de68b5b2
  • Nachfolger 014942ea

EmailJournal: bei 'application/octet-stream' versuche mime-Typ zu raten

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
use List::Util qw(first);
use List::MoreUtils qw(any);
use File::MimeInfo::Magic;
use Rose::Object::MakeMethods::Generic
(
......
$::form->error(t8('You do not have permission to access this entry.'));
}
my $mime_type = $attachment->mime_type;
if ($mime_type eq 'application/octet-stream') {
# try to guess the mime_type
if ($attachment->content =~ m/^%PDF/) {
$mime_type = 'application/pdf';
} else {
$mime_type = File::MimeInfo::Magic::mimetype($attachment->name);
$mime_type = 'text/plain' if $mime_type eq 'application/octet-stream';
}
}
return $self->send_file(
\$attachment->content,
name => $attachment->name,
type => $attachment->mime_type,
type => $mime_type,
content_disposition => 'inline',
);
}

Auch abrufbar als: Unified diff