Rogowicz Ответов: 1

Распаковки октет-поток кодируется в файл MIME


У меня есть устройство, которое передает данные в мое приложение "сервер". Устройство подключается и отправляет составной MIME-файл/поток/строку. Я могу получить это как поток и преобразовать его в строку, поток или bytearray, я могу разобрать его, чтобы разделить данные на границах MIME, но я не могу преобразовать поток октетов во что-то полезное. Вот данные MIME

--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SENDDATATRACE"

YES
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODE"

LOGFILEUPLOAD
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SERIALNUMBER"

001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="PASSWORD"

password
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOOPNAME"

001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSIP"

127.0.0.1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSPORT"

-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICE"

1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICENAME"

Power Meter Test 1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPE"

Obvius Power Meter Simulator
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPENUMBER"

-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICECLASS"

74
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MD5CHECKSUM"

edba30720900d5068bdd6a960d8a98c9
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILESIZE"

11240
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILETIME"

2012-12-16 12:29:02
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOGFILE"; filename="/var/log/modbus/mb-001.50CDBE8F_1.log.gz"
Content-Type: application/octet-stream;

� 4�R�}I�d;��OQ��D�p ������*H>�3ϒL�G�pw�I� ��BL�W�/���a��?���/)�^��O*�b���c���O>q�1���)�ϐ���������>9��)|Z�/�o�})�/����2�����?Ώ���AR�I�>����.��s:�����s��<f_�'�5�p����O�s��#�����6{���$]ޘ��3�U�"D��B��4�|r�i�9a�4�3b����㚸�N�������){5�8g-��.C�ي���O|�}��9�c����K�6�9����[i���?��Clϛ}��K�[�چ^W ��O���z�sa��['�lJ������S�Eͩ䁿�

�~�}�'Ŷ{nT��W?a~�n��   �O�:��ߺy;�e��m�20wm��ҧ&�`��į��.W�w��<�^)�|_�B�]�1>���Kɮϼ������I�K�i�'�-�^f�@��s���Ϋ|j��U�T0�T a�.�m)���Pe�ǐ��Ern��Q�}��;��[��گ5Iz�����e�E,���8Eq
tK�O��T��-�=�/G�����G����3�Û���h{�l�Eu���<\A��e�U���>v`\��c6�h2�uoyWl�`�қ��T�z��Sz��u.٦���@U��a2���<��U�-=���56�:���rVM5��.�ؕV1[��z��jS��n�n�$�+S|��e�iSQʹQU�*��O߳�d��oP��3b�����nBت�>���l:��9����  �;`�(�w�jk���j�k�����@��oY�u6�6��EӢ=�5΍�lޭ�m�U�腳���ф9N1���h�T���w7ꠊ?��@�e`dU%~1�q�nq�R�m��`J�:z`ٴR��\�u$�ؗ̅�g�ɲ�c���W���瀾���-&���Q��lg ~��T��o�JҮ�'�П�KR��p�-jǎ�#��P��g����zZ���m!�sV�1�UF��'�:����^8�*ʶ�"T��~՟��8���������W�Z���U�]�`�&!��_�J��o����
�pB��
,{��d�^�,g[�����Kj��h�G�,b4e��v�;�`��V�����ܲ!p�:�h|�]�R��m~�V�)2�E3�+jë�K���_R��(C�#��JS��$�T�װ�%��0��L�Z� ��z�k;�<z^g0~�B����'�}�zY�J���`�P��7(�

�pB�B�nwf���p5х���y{.%&Z�}�/�hn��5ZTP�eѓF��+�S(�

1 Ответов

Рейтинг:
0

Rogowicz

Мне кажется, что большая часть вопроса была отрезана. Он не будет показывать остальную часть октетного потока в данных MIME, и он не показывал журнал с устройства. Вот журнал, так как я думаю, что это будет уместно.

1/httpupload: LogFileUpload: Begin processing file "/var/log/modbus/mb-001.50CDBE8F_1.log.gz"      ----------------
1/httpupload: TCPConnect: Connecting to server 192.168.1.163:80 (via 192.168.1.163:80).
1/httpupload: TCPConnect: Established connection to server 192.168.1.163:80 (via 192.168.1.163:80).
1/httpupload: SendDataFile: Start file: "/var/log/modbus/mb-001.50CDBE8F_1.log.gz" as "/var/log/modbus/mb-001.50CDBE8F_1.log.gz" (size 11240).
1/httpupload: SendDataFile: Original log filesize = 11240,  total bodysize = 13116.
1/httpupload: SEND: POST  HTTP/1.0
Host: 192.168.1.163:80
1/httpupload: SEND: Connection: close
1/httpupload: SEND: Content-Length: 13116
1/httpupload: SEND: Content-Type: multipart/form-data; boundary=MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
1/httpupload: SEND: Pragma: no-cache
1/httpupload: SEND: Authorization: Basic MDAxRUM2MDUxMjIxOnBhc3N3b3Jk
1/httpupload: SEND: User-Agent: Mozilla/4.0 (compatible; httpupload.c 1.41; Linux; serial 001EC6051221)
1/httpupload: SEND: --MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SENDDATATRACE"
YES
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODE"
LOGFILEUPLOAD
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SERIALNUMBER"
001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="PASSWORD"
password
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOOPNAME"
001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSIP"
127.0.0.1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSPORT"
-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICE"
1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICENAME"
Power Meter Test 1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPE"
Obvius Power Meter Simulator
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPENUMBER"
-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICECLASS"
74
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MD5CHECKSUM"
edba30720900d5068bdd6a960d8a98c9
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILESIZE"
11240
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILETIME"
2012-12-16 12:29:02
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOGFILE"; filename="/var/log/modbus/mb-001.50CDBE8F_1.log.gz"
Content-Type: application/octet-stream;
1/httpupload: SendDataFile: TCP connection MSS = 1448
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1104 bytes of data
1/httpupload: SEND:
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY--
1/httpupload: SendDataFile: Finished sending file to remote server.