Open jbiechele opened 1 year ago
Hello @jbiechele. Thank you very much for your suggestion. Are you really sure about that? Looking at the documentation and the tests(test/ZammadAPIClient/Resource/TicketArticleTest.php
), it seems like getAttachmentContent()
is supposed to return the actual content.
Hello Martin,
yes I'm sure, at least with my PHP code. Below I post the two relevant PHP statements and the output in my log file.
Maybe I'm doing something wrong?
Best wishes, Josef
// --- // Get article attachment content ($attachment['id'] is substituted with the correct attachment id) // Result: GuzzleHttp\Psr7\Stream Object // --- $attachment_content = $article->getAttachmentContent($attachment['id']);
// My log of: print_r($attachment_content, true) // --- [2023-01-05 11:42:25] attachment_content: GuzzleHttp\Psr7\Stream Object ( [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #22 [size:GuzzleHttp\Psr7\Stream:private] => [seekable:GuzzleHttp\Psr7\Stream:private] => 1 [readable:GuzzleHttp\Psr7\Stream:private] => 1 [writable:GuzzleHttp\Psr7\Stream:private] => 1 [uri:GuzzleHttp\Psr7\Stream:private] => php://temp [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array ( )
)
// --- // Get article attachment content // Result: the contents of the Guzzle object aka the image file itsself // --- $guzzle_contents = $attachment_content->getContents();
// My log of: print_r($guzzle_contents, true) // --- [2023-01-05 11:42:25] guzzle_contents: ?PNG
IHDR:k?:?
iCCPICC @.**@.??? ?]D????Z?#v??ET?uQ??&t?W?7?7w??ϙ??9w??;h???Ź?&y?I\x0c\J??P?)@@.?U'?????k?? ?y ????yy??%e??? ? t$0@??p?W?p???$ı @.?˕d??yF!/j??C?"? ... ...
On 5. Jan 2023, at 07:50, Martin Gruner @.***> wrote:
Hello @jbiechele https://github.com/jbiechele. Thank you very much for your suggestion. Are you really sure about that? Looking at the documentation and the tests(test/ZammadAPIClient/Resource/TicketArticleTest.php), it seems like getAttachmentContent() is supposed to return the actual content.
— Reply to this email directly, view it on GitHub https://github.com/zammad/zammad-api-client-php/issues/52#issuecomment-1371844344, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASVT36IZKYLC2QZ2QBWPO3WQZVNFANCNFSM6AAAAAATGTXHVY. You are receiving this because you were mentioned.
Just a small additional information for section "Fetching content of ticket article attachments", where is mentioned:
$attachment_content = $ticket_article->getAttachmentContent(23);
Additonal information: "The output of $ticket_article->getAttachmentContent() is a GuzzleHttp\Psr7\Stream Object. To access the content ("body") of this object, use
$guzzle_contents = $attachment_content->getContents();
"It took me a while to figure out how to access the "body" or content of the GuzzleHttp\Psr7\Stream object for further processing. Maybe this addition to the documentation can save someone time.
By the way thank you for the great PHP client for Zammad API.