[rt-users] Processing attachments outside RT
Emmanuel Lacour
elacour at easter-eggs.com
Tue Jul 1 06:09:22 EDT 2014
On Tue, Jul 01, 2014 at 06:03:21PM +0800, pj loh wrote:
> Hi,
Hi,
[...]
> I've looked through the RT::Attachment documentation, experimented with
> it, and also searched through the RT mailing list archives. The best I can
> do is to display the content of the attachment, but I cannot figure out
> how to 'export' an attachment to the filesystem. Is this even possible
> within RT? I've not come across anyone discussing anything similar.
here is an example I used to dump tickets to files:
my $Attachments = $Transaction->Attachments;
$Attachments->OrderBy( FIELD => 'id', ORDER => 'ASC' );
while ( my $Attachment = $Attachments->Next ) {
next unless ( $Attachment->Filename );
my $filename = $Attachment->Filename;
$filename =~ s/\//-/g;
my $file_path = $attachments_dir."/".$Ticket->id."-".$filename;
open( FILE, '>' ,$file_path ) or die "Can't open $file_path: $!\n";
print FILE $Attachment->OriginalContent;
close ( FILE );
}
--
Easter-eggs Spécialiste GNU/Linux
44-46 rue de l'Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour at easter-eggs.com - http://www.easter-eggs.com
More information about the rt-users
mailing list