X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FREST%2F1.0%2Fticket%2Fcomment;h=177690d6ade33f69dcb8ee3025701c017c6e3c90;hb=ed1f84b4e8f626245995ecda5afcf83092c153b2;hp=475e3a88db89b9feed5bacb305ee2299a56a54f5;hpb=7588a4ac90a9b07c08a3107cd1107d773be1c991;p=freeside.git diff --git a/rt/share/html/REST/1.0/ticket/comment b/rt/share/html/REST/1.0/ticket/comment index 475e3a88d..177690d6a 100755 --- a/rt/share/html/REST/1.0/ticket/comment +++ b/rt/share/html/REST/1.0/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -52,10 +52,7 @@ $content <%INIT> use MIME::Entity; -use LWP::MediaTypes; use RT::Interface::REST; -use File::Temp qw(tempfile); -my @tmp_files; my $ticket = RT::Ticket->new($session{CurrentUser}); my $object = $r->path_info; @@ -111,39 +108,19 @@ my $ent = MIME::Entity->build( Type => "multipart/mixed", 'X-RT-Interface' => 'REST', ); -$ent->attach(Data => $k->{Text}) if $k->{Text}; +$ent->attach( + Type => "text/plain", + Charset => "UTF-8", + Data => Encode::encode( "UTF-8", $k->{Text} ), +) if $k->{Text}; -my $i = 1; -foreach my $att (@atts) { - local $/=undef; - my $file = $att; - $file =~ s#^.*[\\/]##; - - my $fh = $cgi->upload("attachment_$i"); - if ($fh) { - my $buf; - my ($w, $tmp) = tempfile(); - push @tmp_files, $tmp; - my $info = $cgi->uploadInfo(); - - while (sysread($fh, $buf, 8192)) { - syswrite($w, $buf); - } - - $ent->attach( - Path => $tmp, - Type => $info->{'Content-Type'} || guess_media_type($tmp), - Filename => $file, - Disposition => "attachment" - ); - } - else { +{ + my ($res, $msg) = process_attachments($ent, @atts); + unless ( $res ) { $status = "400 Bad Request"; - $output = "No attachment for $att.\n"; + $output = "$msg\n"; goto OUTPUT; } - - $i++; } $ticket->Load($object); @@ -177,7 +154,6 @@ if ($k->{Status}) { OUTPUT: -unlink @tmp_files; RT/<% $RT::VERSION %> <% $status %>