Hello
I am geting attachment data with Content()
.
Problem is that in mysql I can see on Headers that it shoud be base64 encoded, but when I do ContentEncoding() it says “none”.
I can see that in mysql it is type LONGBLOB, so with Content() I should get base64, right?
I am asking becuase data from Content() can ne be decoded and it looks like:
"
01E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E\\u0014P\\u0001E
"
which for sure it is not ok. This looks like on server, which receives this request.
What I do:
my $c=0;
my %hash =();
while (my $attach = $attachments->Next) {
$content = $attach->Content();
$hash{$c}{"filename"}=$attach->Filename();
$hash{$c}{"content"}=$content;
$hash{$c}{"contentType"}=$attach->ContentType();
$c++;
}
my $header = ['Content-Type' => 'application/json; charset=UTF-8'];
my $encoded_data = encode_json(\%hash);
my $r = HTTP::Request->new('POST', $url, $header, $encoded_data);
my $resp = $ua->request($r);
if ($resp->is_success) {
my $message = $resp->decoded_content;
RT::Logger->debug("Received reply: $message\n");
}
thank you!
miha