Corrupted attachment file is uploaded

Hi,

I’m trying to upload an attachment to a specific issue in my Custom UI app.
I’m using this endpoint in the Jira API.

I tried to upload it using resolve from @forge/bridge, but it doesn’t work. I saw here in the forum that someone suggested using the requestJira option. This option works fine for text files, but when I try to upload an image/pdf/etc, the file is uploaded but it’s corrupted. When I download the attachment and compare it with the original file that I uploaded, I can see that something is wrong with its encoding.

This is how I’m uploading the attachment:

const form = new FormData();

attachments.forEach((attachment) => {
	form.append('file', attachment, attachment.name);
});

const response = await requestJira(`/rest/api/2/issue/AP-9/attachments`, {
	method: 'POST',
	body: form,
	headers: {
		Accept: 'application/json',
		'X-Atlassian-Token': 'no-check'
	}
});

So, I have two questions:

  1. How can I fix the encoding issue? How can I upload attachments that are not text files?

  2. Is there any way to upload attachments using resolver rather than requestJira?

Thanks,
Amit

Hi @amityahav,
Thank you for reaching out!
We understood the issue and unfortunately we don’t have a solution to this at the moment and will be looking into it soon.
For Qn 2 : using resolver will not help here as they will be same underneath

Hi @LashaniPerera,

Thanks for your quick response.
Are you sure that there’s nothing you can do about it? It’s a bit weird that I can’t upload files that are not text files without them being corrupted…

Is there any way I can control the file encoding? It’s a huge blocker for me.

@LashaniPerera

Above is not an acceptable answer for a production framework bug report.
Basic functionality, such as file upload, should work.
Especially since it has been already reported in the past as broken:

I’ve verified that it works fine when triggering the REST API directly from the postman. It must be something that has to do with FaaS or the headers.

Would you mind checking again and providing us with a solution?

1 Like

Bump… anyone?

Hi ,
I am experiencing the same issue when uploading a file.
It’s a huge blocker for my development team.

From what I can tell, this is now captured in: [FRGE-635] - Ecosystem Jira

Please watch, comment, and vote there.

1 Like