Download and display Jira issue attachments with Forge

Hey there :slight_smile:

I’m trying to display Jira issue attachments (images) within my Custom UI.

I’m using this function to obtain a blob URL. Afterwards I use the URL as the src attribute of an img tag to display the image. Unfortunately the resulting image is broken.

export async function fetchAttachmentById({attachmentId}: { attachmentId: string }) {
    const response = await requestJira("/rest/api/3/attachment/content/" + attachmentId);
    if (!response.ok || !response.body) {
        throw new Error("Failed request.");
    }
    const blob = await response.blob();
    return URL.createObjectURL(blob);
}

The dev tools show that the Forge bridge downloads a file. But its content seems to be broken. Maybe the content gets corrupted through the PostMessage API Forge uses under the hood?

I’ve tried multiple things (Also fiddled around with the “redirect” param of the REST Api to get a direct URL from the location header, but the header gets omitted.)

A working code sample would be great. Or maybe an Atlassian could have a look at this behavior to confirm this is a bug.

Please help! :slight_smile: