question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect response.data/response.base64 for Android when using fetch

See original GitHub issue

Hello @Traviskn @mheins57 After the latest 0.11.1 version release I have tried to add this new version to my project and fount possibly regression issue on Android:

When we are using

const response = await RNFetchBlob.fetch('GET', uri);
const imageData = response.data;
const imageBase64 = response.base64();

response.data looks broken, previuosly it was simple base64 string. response.base64() throws an error


Uncaught InvalidCharacterError {message: "The string to be encoded contains characters outside of the Latin1 range."}

In version 0.10.16 everything looks fine. On iOS both versions are working fine. I’m using react-native@0.61.1

As example i’m fetching this file: https://api-dev01.elateral-dev.io/file/dev01/S1GbfMFDN And get broken response.data instead of normal base64 string:

"����JFIF��C��C���t��	
��F	!	13�"#AQRSs��a��$2Bbq��C���
5c������	��C	!1"A2Qaq���#BRs������3S�Cb$r���%���?�Hch_4/t/�l�
�
z����7������Nd�9'���>�W��������'��`���L�x0k�I�G�X;b��~S>������ؾ�_�χ�����僶/��3������'��`���L�x0k�I�G�X;b��~S>������ؾ�_�χ�����僶/��3������'��`���L�x0k�I�G�X;b��~S>������ؾ�_�χ�����僶/��3������'��a2p��g͍>i=�j|�Rq�����G��ՇԎ������՘��)�����ǃ����/����~v�|&<������X�EUc����v�_�˶�_4�]��>���jS�"砸��appa./k����papp`���/n�80a2w�g�'�'S���}I�?�ȘP���7�g�����˓�$���Ly���s��Q��d��f|�r����Lv��9��n߉Ͽ�������ՙ�>Q�i̟9��8���W�sl�e��i�bDm3�)W��M���Q[�I2+l�,[l�%��4���%��*��l&��VatE!YؐB�V��E���ٖF��nj�e��n9s$v����&Q��e�F�+�X�P�g�l�d�N�X����Q�J?>k����\��$��#p%2S���%%<�;/��;vJ�H�k��:����KΘ٤���X��}�̦=Lj�yMh��"-���epLɧ<���ε�$:l�D�eY۽Je��5/��κBI�P�9�BM:��
.ASڱh�s���'0�ڎ�!r��iX�dfQ�2J�u���N����Y�IaC�}k[���M�R)Th�r_/��$c��K@<|����`[%�����+>I�S��EOR[1|�e"*�W�,�'�H&�5h�H�4��<�������	�\gĹ�GM�We�r�v�C�Y!yr���)>_��jZYdJ�)�WTfӵ��Wo�Rub\�j�x�Y���������0#H�9f� X�ܩq���(�Y��Xɏ���xBzJ��ia��5�S�+vIc��`�.ie~�1�"%")�`�Zh����I�W]�eT\-KW�d�!��.�(�?�����5�Z���*Jh�7�Ҝ=D��i桒���2����=�|�+��i#�Fʶ����bC�O�X�0%d�c(����3R+��ž(��*3����K,�h�
�#�T��zt�4�eI#�*�$��#t:�r�Ӵ����WǾ����l�$���VoB�rjţ��+�#J�CUĔf5S��heC
F_qQ��O_-U1x��G��� ��!AdzZ�V��k��d�������^(q���Y=�Q:
�d��s��r������ezh�Z��51IQD��5B�3��yW��=0m'���f<ǼI��\IA��SRIg6I��[�V�2��(syjg�si�������E��.��Z�0�*�Ww�qk�A����X�5Lm���ȟc!R�-�l�,!XT���HQ��k�T�UP�>��y�̧�%��&��54cƥ�JI'�秬AN�J��T�Ť���7�g~�2�*
����Zl�+�3Z��j+���2�8�3���i����&z�"	%D<QL�(@2ƽ �e���B���ō8%|J����Vr��~ӫ�%��k[",VG-Y;��H��琤4�G3h��e��f���8^L–6+M�]���>4c�Vt�B��4��W��qͨ�ϐ�M-5l2�&SMsVEC��B��'��L�8Z�ML�K��$���̨��&iċ~j������FKk�F��1�N1$Ie����0�Ҙb+�6�3��ҾQ�hyt�
��b� i�<��&�Rf�4���3������	�v�d΅ViHjzjPb�5���㆒��S�-3� ��ѕ�d�Wx�Fw�g�'�'S����Ry���&��B�
��}g��7���I?;b�pp`�c���Q���c��-�I�8��:���R�����	�U1�D�����rѬt����
�[)���FA2�j�uew'�,�,��MS&��ۡ/�a��7^YHC�2��xtF@"ž=:��)%�"��\��Q�r�6XWJ��W-����;R�W�4r�:�ֽ7�wX���5x�IP�>�j���^�L�������bx����z��@Ab������C���ǚAr����é�/���k�ᚩ�W���&@�p��`�;�����3�U�]��$BL���V���J|��$�zj�W(�;
ӤD�]�����O�ܒ1��s�b�*x�i*�r�k4��Ҫ��%�l0e�n�7'>��:�
��k|�QXE���S����܌�xsV0+}kgD�L�d �m;���H2J�+�ͦ4�SG-u4�L��Z#��[̓�%��RK��5J�E� �g��%WR.iM�TRdم%E+��eQ��H�A4T���Z|���zj�k7Ɏ�KP�Td��6d��ǥÇ&����Gd"V�\�6�֞��P���M��N�v�}�XS�"ˈ�䕙_�F�犓1�T�εM9�M%mB=8d��іSS��h��P�K���(�o���"���(�s^�d��se�c���ܻ5�2��1Te�#M�y�ueBT>sKGV�RR�Q�
�k;~
^)��rC��e:�)��d�c�AB	�
$�B�>��c��6�t�8,�g��UA΢�s����znf��r��8^

Could you please check this issue on Android please? Thank you

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:18

github_iconTop GitHub Comments

2reactions
saadmutaharcommented, Jan 27, 2020

Hi @Traviskn @oleksandr-dziuban
I am trying with the lates version and the issue is still coming in android.

I am using `RNFetchBlob.fetch(‘POST’, REQUEST_URL, {

            'Accept': 'application/json',
            'Content-Type': 'multipart/form-data',
        },
        data
        )
        .then((response) => response.json())
        .then((responseData) => {
            console.log(responseData); })`

response data looks broken I’m using react-native@0.61.3

I am getting a broken response data instead of normal string. Example: Message: "تم التحميل بنجاح "

1reaction
Traviskncommented, Sep 26, 2019

Ok, I’ll see about adding back the case for base 64 and opening a PR as soon as I can

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native content uri to base64 string - Stack Overflow
const response = await ReactNativeBlobUtil.fetch('GET', res.uri); const data = response.base64(); ReactNativeBlobUtil.wrap(decodeURIComponent( ...
Read more >
XMLHttpRequest.responseType - Web APIs | MDN
The XMLHttpRequest property responseType is an enumerated string value specifying the type of data contained in the response.
Read more >
Convert An Image To A DataURL or Base64 String Using ...
In this short tutorial we explore 3 different JavaScript methods to convert an image into a Base64 string. We look at converting a...
Read more >
CardPointe Gateway API - Developer Center
Basic Authorization is expected, using a Base64-encoded username and password string as the value. If this value is incorrect or not provided in...
Read more >
Handling binary data using Amazon API Gateway HTTP APIs
Use curl to request an unknown image format and return a base64 encoded answer. curl "${NOISE_API}?demo64Flag=1" -H 'Accept: image/unknown' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found