In my Custom UI app I’m attempting to fetch and display attachments to Jira tickets (image files). To do this I’m fetching the data by calling await requestJira("/secure/attachment/<attachmentId>/attachment")
since calling this method requires authentication that requestJira
augments the request with.
When I request a PNG image I can see it successfully returned and rendered in the browser dev tools, however when I attempt to use it in my app (for example base64-encoding it and displaying it in an image tag), the image is no longer valid.
After doing some digging, it appears that the response body from requestJira
has already been interpreted as text – since reading the body
stream returns PNG contents with Unicode replacement characters:
�PNG
IHDR00*lPLTE !$\^a�������OO/IDATxcm����=8����'������A(��������)-Jej�IEND�B`�
I found a potentially relevant snippet of code in the async-forge-ui-iframe-renderer file (note the body: r.body ? await r.text()
):
fetchProduct: async({restPath: e, product: t, fetchRequestInit: n})=>{
const r = await B(e, t, n)
, {status: o, statusText: i} = r;
return {
headers: Object.fromEntries(r.headers.entries()),
status: o,
statusText: i,
body: r.body ? await r.text() : void 0
}
}
When I use the api.asUser().requestJira
method to call this endpoint in my application backend I see the image successfully returned as binary data and I can use it correctly. Since it works in the backend api
implementation I was wondering whether this is a bug in the @forge/bridge
implementation, and if so, if there is any way to work around it?
Thanks very much!