douzhenqun1271 2017-02-06 09:57
浏览 79

请求跟踪器4.2.8 PHP REST API下载附件

I am trying to download attachments from RT 4.2.8 tickets using PHP REST API (https://github.com/dersam/RTPHPLib). I've used Ticket Attachment Content and Ticket Attachment. They return some kind of string or array like this (basically it outputs the file content):

   Array
(
    [%PDF-1.4
%����
] => 
    [10 0 obj
<>
endobj

] => 
    [15 0 obj
<>/Filter/FlateDecode/ID[<4DCDA9C01A05A34BB7A89B62345FD905><4DCDA9C01A05A34BB7A89B62345FD905>]/Index[10 7]/Info 9 0 R/Length 36/Prev 805889/Root 11 0 R/Size 17/Type/XRef/W[1 2 0]>>stream
] => 
    [h�bbd`b`�db`�eb`����^��"��
] => 
    [endstream
endobj
startxref
] => 
    [0
] => 
    [%%EOF
] => 
    [16 0 obj
<>stream
] => 
    [h�b```f``����33 �������L f(f`�ca```h�o�1���iF �`�] => 
    [O
] => 
    [endstream
endobj
11 0 obj
<>
endobj
12 0 obj
<>>>/Rotate 270/Type/Page>>
endobj

I've tried to write this with php fwrite/file_put_contents to a tmp file and then download it, but it won't open.

How can I download the ticket attachments locally? I want this to be dynamic (no matter the file extension)

  • 写回答

1条回答 默认 最新

  • dongxuan1314 2017-03-29 15:00
    关注

    For binary content, it is necessary to make an additional call to getAttachmentContent. This will return the file contents in their original encoding.

    The issue comes from RT using UTF-8 in its response, which also encodes the Content section. Unfortunately, RT does not store the original encoding of the attachment, resulting in an unreliable Content section, making it impossible for RTPHPLib to guess intelligently.

    See https://github.com/dersam/RTPHPLib/issues/66 for some recent discussion on this.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog