MrRefactoring / jira.js

A JavaScript/TypeScript wrapper for the JIRA Cloud, Service Desk and Agile REST API
https://mrrefactoring.github.io/jira.js/
MIT License
349 stars 46 forks source link

binary data returned as a string #272

Closed dreamboyx1 closed 8 months ago

dreamboyx1 commented 10 months ago

I've been using the avatar endpoints to fetch png data because for certain avatars I need to add an auth token to the request. The calls to getAvatarImageBy* return binary data that seem to be created by Axios' Body.text(). This is because these Axios calls use the default responseType which, for this data, is "text". My understanding is that these returned strings are USVStrings and these strings do not allow unpaired surrogate code points. And, because the response is decoded as UTF-8, some bytes from the binary file can't be mapped to characters correctly making it not possible to properly decode these string. As such, after a lot of effort, I've been unable to extract the original binary image (png) data from these strings.

I'm no expert in this area. Is this a bug? Or, do the authors know of a way to extract the png data that I'm simply just missing? My current solution is that I bypass this library completely and use axios directly where I can specify an responseType as "arraybuffer" in the axios config settings.