I have a custom field for uploading files. How can I get the content of the file in the script?
I tried the below script:
my $filecontent=$self->TicketObj->CustomFieldValues('file');
while (my $i=$filecontent->Next){
RT::Logger->info($i->CustomFieldObj->Values('FileContent'));
}
But can only get below output.
[info]::RT::CustomFieldValues=HASH(0x55d66fcc1ea0) (eval 1843):19)
How can I get the real file content? Thanks.
I am not sure off the top of my head, what do you see from this?
my $filecontent = $self->TicketObj->FirstCustomFieldValue('file');
RT::Logger->info($filecontent->Content);
@knation Thank you!. FirstCustomFieldValue can get the file name, but not the content. I got the below output with your code:
[402020] [Fri Jul 8 01:16:33 2022] [error]: Scrip 36 IsApplicable failed: Can't locate object method "Load" via package "xxxx.pdf" (perhaps you forgot to load "xxxx.pdf"?) at (eval 1273) line 16.
After checking the database and documents, I finally found the solution.
if (defined $self->TicketObj->FirstCustomFieldValue('file') ) {
my $files=$self->TicketObj->CustomFieldValues('file');
while (my $i=$files->Next){
my $file_name=$i->Content;
my $file_content=$i->LargeContent;
last;
}
}