X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rt%2Fshare%2Fhtml%2FREST%2F1.0%2Fticket%2Fcomment;h=4c058b6abcb80555cd6628228c907b4846063d13;hb=e9e0cf0989259b94d9758eceff448666a2e5a5cc;hp=768a4688b5c4cfa43b1f5545e98680e2fa92ca4a;hpb=43a06151e47d2c59b833cbd8c26d97865ee850b6;p=freeside.git diff --git a/rt/share/html/REST/1.0/ticket/comment b/rt/share/html/REST/1.0/ticket/comment index 768a4688b..4c058b6ab 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-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -52,9 +52,7 @@ $content <%INIT> use MIME::Entity; -use LWP::MediaTypes; use RT::Interface::REST; -use File::Temp qw(tempfile); my $ticket = RT::Ticket->new($session{CurrentUser}); my $object = $r->path_info; @@ -106,39 +104,19 @@ if (!$k->{Text} && @atts == 0) { } my $cgi = $m->cgi_object; -my $ent = MIME::Entity->build(Type => "multipart/mixed"); +my $ent = MIME::Entity->build( + Type => "multipart/mixed", + 'X-RT-Interface' => 'REST', +); $ent->attach(Data => $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(); - 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); @@ -171,6 +149,7 @@ if ($k->{Status}) { } OUTPUT: + RT/<% $RT::VERSION %> <% $status %>