Image Issue Attachment via REST API Corrupts Image

Wafir Admin February 24, 2021

Hello,

I am trying to attach a PNG to an issue on a Jira Cloud project via the Jira Cloud REST API (v3). However, the resulting image attachment on Jira is corrupted. I also get a 200 response back from the API.

Here's the thumbnail for the corrupted image:

Screenshot 2021-02-24 163026.png

I am uploading the attachment with the property name "file", I am sending it as a `multipart/form-data`, and I am not explicitly setting the Content-Type header.

The image is sourced from a web client, where I then create a FormData object, attach the image (as a blob with its mime type set to 'image/png'), and post it to Jira through a proxy. The blob's binary data is correct - I double checked this by 1) converting it to a data URI and then converting that to a PNG with an online conversion tool, and 2) by saving it to a file on my computer and hexdumping it. 

My proxy does not modify the request except for adding a few unrelated headers. I am using `express-http-proxy` with `serverless-http` on AWS Lambda/Serverless Framework. I am using Node v12.

Below is the hexdumps for the correct/uncorrupted image before it is sent to Jira (right) and the corrupted image after being sent to Jira (left)

Screenshot 2021-02-24 163505.png

Note that the corrupted image (left) does not conform to PNG's required header, while the uncorrupted one does. Also notice that there seem to be chunks within the corrupted image that match chunks within the correct image, albeit displaced a few bytes. This could be a coincidence. 

Sending the correct file using cURL works fine. Here's the relevant portion of the log:

> POST /rest/api/3/issue/WT-17/attachments HTTP/2
> Host: wafirtest.atlassian.net
> Authorization: Basic <redacted>
> User-Agent: curl/7.58.0
> Accept: */*
> X-Atlassian-Token: no-check
> Content-Length: 195878
> Content-Type: multipart/form-data; boundary=------------------------b1d0e3f361744ee0

Here are the request headers from Chrome DevTools:

Screenshot 2021-02-24 164038.png

Here is the top part of the request body:

Screenshot 2021-02-24 164146.png

Notice that the header is valid.

 

Any ideas for what's going on? Let me know if I can provide any more information.

1 answer

0 votes
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2021

Hi @Wafir Admin 

Welcome to community! You mentioned you're not explicitly setting the headers. Why don't you try setting it and see if the result is different? Probably that could be the issue here. From what you explained, if the binary data can be converted back to an image then for the most part of it, the data is correct. 

Wafir Admin February 25, 2021

Hi Prince,

Thank you for the response. Per this article, this seems unadvised. I attempted it anyways to no avail. Either way, the Content-Type header was being properly set by the browser and was left unmodified via the proxy.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events