2020-05-05 14:29:54.112 17172-17273/com.mobile.qa D/OkHttp: --> POST https://some.url.com/messages/attachments/add
2020-05-05 14:29:54.112 17172-17273/com.mobile.qa D/OkHttp: Content-Type: multipart/form-data; boundary=a95001c6-60d9-45d7-ae12-2bcc469932ba
2020-05-05 14:29:54.113 17172-17273/com.mobile.qa D/OkHttp: Content-Length: 1560240
2020-05-05 14:29:54.113 17172-17273/com.mobile.qa D/OkHttp: Authorization: Bearer 010DB4521D02851702F831C178A3C95813FC2A8CEC8765A3E0F9544CB70DCA14CDC31CB08F4255259A9484D563A6CB423ABE018275CBE24C967E9560B590A5D4F73AE517E37EC3B72D74C8A14DF3F73C8EEF6F77CB4D8A74BB0DF8710C696E75F9B2357D5FBB57C8EC1E49B4CCCB51B1E78B1018866F3BB3E81188AECC6932B511CD025EDD7074CEB40B00B0655030ACB0BA9C51573B56AF7BC39310835EF24907F0A47B8A469A48596ACDFA55BB8924DCF7D1AE455B9EC029F3F3EAC1255D4F8ADB044EBC71545E5E330A90B7FD0A1C0DF0DF416CDBEE32BD5F1E9370000AAE2F6ED367C640204DF0A962CE4F0807F32F7CB9B95FD80A7E45B8866FD4516D7ED77A3740F8D6CCEBF2434D26915AF69DC73515C48398C2510C981AA2A96B230A2FBBC3040179CB85565B1E31E1F960407831F9B03BE29225EFF874DED24DABD50B56B2AEE28B6639D33947FBFCEC2EA3B083B4820948449C8B67913CF680B3C3B0C69A73C266765BA9A5A18C0A87BF24EC23B8F8EF66A5FA9A7A90515ECEFC475536B6CF335B8A520452F8F0244EF43A581BC89223814DC687533EE06662113C28D0E7A9B176CC40E610455FC4BB53AF8B8F7BC42E6EB2B3250EEB98B72C99BCBBB6F50AA587CA1BE0BD833021F20F77C04458475DAB72C7EE5561F3A5E8AC44FAE267E614E8604B36808E70CB2BA44BE7BF3707DE945A51D8DD269FF5E4FC2330A8421F5928DD318224FD90F6C481FB638BBE15C4E626B4D44C0B6975C00A24E751926A765F072FC19FA9E5387CEFCE1EAE5D8C2072B01FC1CCAFEB1E975C39D7BD66DA4B16ACA6518946915AA5D43F8787F6DE64FE9BAA9234C9620B4E00D9BB33C460CC
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: --a95001c6-60d9-45d7-ae12-2bcc469932ba
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: Content-Disposition: form-data; name="attachmentUpload"; filename="with_extension.pdf"
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: Content-Type: application/pdf
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: Content-Length: 1560010
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: %PDF-1.3
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: %���������
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: 4 0 obj
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: << /Length 5 0 R /Filter /FlateDecode >>
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: stream
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: x��ݎ\7r���S��q���G�6�z����X{�B;�V��X�%����ȳ��/���>ݚ�4�^?��b�XU,����c����~٦����=�R�k�V��+���O�O|ڦ�&�>��<X��Oߧv�fnF���o�?C�o?���Ƕ;����D�`������f1:ﻕ��.�A���w��jP͋�-��u�q��<����h����}h�{��TEX甎Co|��?��w�+�_:�<���$�a��}�ⱄ<?�|��_��ڟ�v��S?�c{����v�w|�߹;M�:������o^��i��m���������oT�ڻ���o���U�5�段U�/!�݃�MT�ѿ��
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: c[Z^?���U���kL]�^?�dߧBs�xY����j_�[��W6/7e�^�hC^?w�d]�K�������^?��o�C�.���;�ȩ�(�_5�"�����_|�.�cO���;���M�DX�۸���"���A}0>y^?i�4�W1i��F���`��gL�K)�;x-eC�C~�����~�b`٭�Jø�͕Ŷv�/6)Rw�nl_ݷӖ�^?���ˌY��_v���,3D�2q�_�Z^?�2Y�M�T��j����0�l"U��^?s��j��P��%l�&'p��w��@��br��'?�
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: ���̬N�v�1�m?u�i��ȸ�ec؎�ٸN�}�q��f�*ͧkY^L����p1�"���zZ:5s��6������}3�|3rK��z����/д^L�a��ʄ�;G�R��GSO=^L:�M=F~�$�AإPn`�fby�̳�yٖa��v�1�Nn^?\�j���`.�eM��VV�B��;����K"�i�O�o�v��8�Ƹ�'�k���>��%���x��@���D�@���Mk�3��;m�&�K�n;��n9-L�w�0��̈́�6�q=�k�:{�idV��;&�������4R���Tij\*2r�V ���h��d1j�*�<83>�nF48C�C@�h5--f�]P����^�v�
2020-05-05 14:29:54.285 17172-17273/com.mobile.qa D/OkHttp: �<8��yAM/
...
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: �/pUY�SFZZϏ�j�]i)v*��:t��rc����X4���F�|���"H�|ϟP��t�a)Ua9�b���Q+��rX����$�(���L.C�ʍ��Sʜ���.���������(�^���ގ#����^MG�>��o���"ija�H�v���u���g<UU�i x�J�7�3�H8���d���_n/L?v�'�Q�k[�X�wh�e* �'���B�CA�GW/�}^?�j��}���D)���{Mm��4{`n�ɩ��볶/���}�����%���,��_�̯^�Cttl�lg0�9pE�����J�1�|��1R��"Ή��*�^?�\���2�t��]�N�������J/�6,���?9[�|�����T����#��*����u|�H����lqE(!�@��F#H��p�X+� ]�^�9�.-��S<��Q�����,�М����g�L�ct�͟�c62��i������YOa(�ج�,�B�ݪ&Eׅ���|\�)���YT@#�^L���� ���S:�V�$re�9�5zh4L&��H[p���X��ـ�;���@F3����0Z��_�3����M��!�[8�+#��Q~8���AuHjkә;J�9���V}ߴ$D[��k�ކne��`�L�=QV�� �������1ma����^?v[���r-���A�e�ƽ�A�:���_�DL�$�+�\���)^��;�wg���;���Yǽ礳>X/�;����3�ȧ6�[Z�7���6�r��ڜj^����������|��6{rlC��l����Ur19/�{F�M�u��2M�T�m9^��c^�n�������vQ��]L:@颅���o���ޞK#����j��t����ޕA��w�����-�(um�s�U�3$zeN��X�_^:ٮ�w��V襩J�DR��� 2;ʫ�Z
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: << /Producer 56 0 R /CreationDate 57 0 R /ModDate 57 0 R >>
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: endobj
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: 0000007598 00000 n
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: 0000007617 00000 n
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: 0000007750 00000 n
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: 0001499540 00000 n
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: 0001500904 00000 n
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: 0001541372 00000 n
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: 0001558520 00000 n
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: %%EOF
2020-05-05 14:29:54.330 17172-17273/com.mobile.qa D/OkHttp: --> END POST (1560240-byte body)
read: unexpected EOF!
private val OK_HTTP_INSTANCE: OkHttpClient =
OkHttpClient.Builder()
.connectTimeout(30L, TimeUnit.SECONDS)
.writeTimeout(30L, TimeUnit.SECONDS)
.readTimeout(30L, TimeUnit.SECONDS)
.cookieJar(CookieJarFactory.cookieJar)
.connectionSpecs(listOf(ConnectionSpec.MODERN_TLS, ConnectionSpec.COMPATIBLE_TLS))
.addInterceptor(AuthInterceptor())
.addInterceptor(RefreshInterceptor())
.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.build()
@Multipart
@POST("messages/attachments/add")
fun addAttachment(@Part attachment: MultipartBody.Part): Single<Attachment>
您可以在标题中查找特定的内容类型。
或者添加自定义头@headers(“multipart:true”)
@Headers("multipart: true")
@Multipart
@POST("messages/attachments/add")
fun addAttachment(@Part attachment: MultipartBody.Part): Single<Attachment>
然后在拦截器中检查自定义头并相应地设置日志记录级别
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
okHttpClientBuilder.addInterceptor(chain -> {
Request original = chain.request();
Request request = original.newBuilder().build();
boolean hasMultipart = request.headers().names().contains("multipart");
logging.setLevel(hasMultipart ? HttpLoggingInterceptor.Level.NONE : HttpLoggingInterceptor.Level.BODY);
return chain.proceed(request);
}).build();
okHttpClientBuilder.addInterceptor(logging);
我正在使用这个音频记录和视频文件,它是工作的,但我想用OKHTTP取代它。我没弄明白。有人能帮我一下吗?
我已经创建了一个使用“多部分/表单数据”的控制器 采样器请求对象 现在,我将尝试使用模拟MVC测试它,但我不知道如何将“多部分/表单数据”作为内容传递。我看到很多使用JSON的示例,但没有使用多部分/表单数据 有没有一种方法可以完成我的请求与多部分/form_data?理想情况下,它需要在MockHttpServletRequest的主体中
问题内容: 我是angular.js的初学者,但是对基础知识有很好的了解。 我要做的是上传文件和一些表单数据作为多部分表单数据。我读到这不是angular的功能,但是3rd party库可以做到这一点。我已经通过git克隆了angular-file-upload,但是仍然无法发布简单的表单和文件。 有人可以提供如何执行此操作的示例,html和js吗? 问题答案: 首先 您无需对结构进行任何特殊更改
不管怎么说,所有的想法和答案都是极其赞赏的。谢谢你的帮助。
当我点击这个api时,我得到错误“415:Unsupported Media type”,这意味着不受支持的头。我想将文件从ARC加载到控制器。 我在pom.xml文件中添加了一些maven依赖项。 我的pom文件:
有人知道如何在中使用吗。Net 4.5与上传? 我在网上找不到任何例子。