Processing attachments outside RT

Hi,

I’m new to the list. I’ve been exploring RT for about a month, trying to
familiarise myself with RT as well as to see how I can customise it for my
purposes. Had some success creating a custom scrip. I’m now trying to work
on a 2nd scrip to perform some additional processing of attachments outside
of RT. My idea goes as follows:

  1. User creates a ticket and attaches a binary file to it. Within RT, the
    ticket will have a life of its own.

  2. Next, I would like to run a scrip upon the ticket creation to detect the
    attachment’s existence (eg. specific filename) and send that attachment to
    be processed by another software. The other software is able to monitor a
    folder to pick up new files for processing, so to put it simply, the scrip
    should be able to ‘export’ the attachment to the filesystem and put it in a
    specific folder.

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.

Thanks,
PJ

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@easter-eggs.com - http://www.easter-eggs.com

Hi Emmanuel,

Thanks! Never occurred to me to use standard PERL code. Will try this out
as soon as I can.

Once again, thanks for taking time to help out.

PJ

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";