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.

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

See original GitHub issue

Feature Request

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

this is the code i use for logging requests :

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

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�Tr*h����z�q����4��G4~En�V>;�-m,6?`.q��3�j�yt��	jo�j��[۷�����¥[�cl`0�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��dZUR�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�31g�]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)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
SleeplessBytecommented, Apr 14, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to log file contents in request body of a multipart/form ...
When uploading a file (i.e., a request type "multipart/form-data") its actual content always begins with the "Content-Type: ...
Read more >
Kotlin - Fuel - Documentation - GitBook
There are several functions to set a Body for the request. If you are looking for a multipart/form-data upload request, checkout the ...
Read more >
Fuel HTTP Library with Kotlin - Baeldung
Support for basic HTTP verbs (GET, POST, DELETE, etc.) both asynchronous and blocking requests; Ability to download and upload a file (multipart ......
Read more >
carmas123 / Fuel Download - JitPack
Log.d("log", request.toString()) //print and header detail //request --> GET (http://httpbin.org/get?key=value) Body : (empty) Headers : (2) Accept-Encoding ...
Read more >
How to send multipart/form-data requests via HttpClient
Here we recommend using the apache open source httpmime toolkit. Next I will show a demo of using HttpClient to send a file...
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