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:
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)
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:
Here is the top part of the request body:
Notice that the header is valid.
Any ideas for what's going on? Let me know if I can provide any more information.
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.
Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event