Fuel: logging request body for multipart/form-data requests -- (Fuel.upload())

Created on 13 Apr 2019  ·  6Comments  ·  Source: kittinunf/fuel

Feature Request

in multipart/formdata requests the body is not logged into the logger

this is the code i use for logging requests :

````kotlin
object AppRequestLogger : FoldableRequestInterceptor {
override fun invoke(next: RequestTransformer): RequestTransformer {
return { request ->
try {
Timber.d(request.toString())
} catch (e: Exception) {
Timber.e(e)
}
next(request)
}
}
}

if (BuildConfig.DEBUG) {
FuelManager.instance.addRequestInterceptor(AppRequestLogger)
}

````

this is my request

kotlin val file = FileUtilsLegacy.getFileFromAssetsAndCopyToCache("image2.jpg", ".jpg", this) "http://alirezaeasazade.ir/upload.php" .httpUpload() .add(InlineDataPart("alireza", "username")) .add(InlineDataPart("awesome", "titles[0]")) .add(InlineDataPart("best programmer", "titles[1]")) .add(InlineDataPart("kotlin programmer", "titles[2]")) .add(FileDataPart(file, name = "fileToUpload")) .responseString { request, response, result -> log(request) log(response.statusCode) log(response.body().jsonPrettyPrint()) }

the log i get right now in my logcat

POST http://turkishads.com/api/v1/insertpost Body : (564019 bytes of multipart/form-data) Headers : (1) Content-Type : multipart/form-data; boundary="da9e771b-1738-4066-80b5-8bc6e953a5bd"

this is what i want to get (this log is from okhttp3 library)

````
POST http://alirezaeasazade.ir/upload.php
Content-Type: multipart/form-data; boundary=6e01c434-af74-4c41-bb62-3b6d31b0307e
D/tagtag: Content-Length: 305729
D/tagtag: --6e01c434-af74-4c41-bb62-3b6d31b0307e
Content-Disposition: form-data; name="user"
Content-Length: 7

alireza
--6e01c434-af74-4c41-bb62-3b6d31b0307e
Content-Disposition: form-data; name="fileToUpload"; filename="VVu1EiAoTT.jpg"
Content-Type: image/jpg
Content-Length: 304910

������JFIF����H��H������qExif����MM��*�����������JFIF������H��H��������

Adobe_CM������Adobe��d��������������
 

















������[���"��������
��?��������������������

������������������

��
3��!1AQa"q�2���B#$R�b34r��C%�S���cs5���&D�TdE£t6�U�e���u��F'�������������Vfv��������7GWgw����������5��!1AQaq"2����B#�R��3$b�r��CScs4�%���&5��D�T�dEU6te����u��F�������������Vfv��������'7GWgw���������
����?�����4�<)��Q��� �+T�"G��!�_�>ekt��ms�u!��ᢗ
I:0��"�¨>�Y�e�����
ژ�<�sO��&�謥��\
�$@�n�da9����ӓ
���pc���CZS��R�#k�Trh����z�q����4��G4~En�V>;�-m,6?.q��3�j�yt�� jo�j��[۷�����¥[�cl0�C���s\�q�f��l��~iU3Oc��^W��l֯����c�=��Ω�n<7����^o�M����!�:��{nU��/a���F�.v�G�KϺ�K���2ڳny6{w���e���^�ޣsbb%��S�yYo��Q�3�h5�����Bek?�;ߏsK_[�L��ШHh�nF@�FŎ��I �}�pO�R�l
=�����%2Jg���i�ޜee/�|
��I%���6tEe}��6���N�@p���)b-�9���ٷR
��Q�:{=O�0x�i���I���k�
�����

��
��_�9\�sd
���9�9�l��Z&>�WWS۵�p{t��
��J��ȫe���;?�Sȱ�ł������}�M9&'� }>4�O�&?I̪��C��h�[6t�
��F���[���TN�'��vG.N�Kg
(�k^�l~��!�
x�Zu��.
�|�V���")*3�)
�3���,�K���#�6���~����q�x�1�x�c} ��}-~�7�]m�uX�I�>hwW^n�ud�>� ��K �<�>�<��H���|�/_Y���\���.�9��]�� �}B�=J�p���6[F�>�8���2�O�}[�xx��0��\ �����7������֤<�\�2@ 'v��!�p�Ȑ}T/���)���X�V�� d ZUR�v$0��i� �BšL���2�5��]h�IR ��L�8Q������o��'�5�+�饬p���#�����v�9��CnF6#�Uq�M@fߔ��dC��1���G�h�'""W��_�GS�TF��D��{��2��\�z�7���\�� ��������&�]u����y�?0�mWq����vs���r D��z�佃un�yxy�z�O�\

{����Ú�ݿYz��6D�v��{�~�f�s�s���;�:�t���c+��l<�1��C�m�\>��Ml������n寃��kvc� ��^=�����VZ��������}����]/՟��^ڬs��wѮ�
O�nn�������V͏
���L�ёo��-�G�ƫ�}%Q��x,q{������;�W
�����%�7���S��i���,#��u5������
O_���g�0���@���c���
X��I�����������
�D������۶�o�1qY?X����z�O,�;�=��
�sZ��q�ē�ΰj���O���A�31
g�]IL:�Zc�7?&Gsk����V�+��o��v.y95:fƝ�A��za���~z�!D����
�|�c,�㘩Dї��o�N>e���WS��6��=��,����W]�^�Tm�&�+l��'R?5���
��Y���ɐ��wD���;�����;

--> END POST (305729-byte body)
````

feature

All 6 comments

Well, you can do it manually - all parts of request at your disposal :)
E.g. you can write String(request.body.toByteArray()) to receive text representation of your binary content. And so on.

This is something we can potentially support. I'll look into it

Thanks , this shouldn't take alot of effort and it's gonna worth it

On Mon, Apr 15, 2019, 1:24 AM Derk-Jan Karrenbeld notifications@github.com
wrote:

This is something we can potentially support. I'll look into it


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/kittinunf/fuel/issues/621#issuecomment-483057455, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AlLmJj0M9TI3U7lbGt0H_Hcf7TgjgL2lks5vg5WEgaJpZM4ct2_q
.

@easazade did you mean to close this?

Would you be okay if we re-opened it? It's still on our list to build/add.

You can unsub here:

image

If you're not okay with that, I'll duplicate the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

georg-jung picture georg-jung  ·  6Comments

erikthered picture erikthered  ·  7Comments

lfmingo picture lfmingo  ·  4Comments

fyi2 picture fyi2  ·  3Comments

Xianyang picture Xianyang  ·  4Comments