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.

Not able to decode multipart response

See original GitHub issue

Q&A (please complete the following information)

  • OS: Windows
  • Browser: Chrome
  • Version: 73.
  • Method of installation: npm
  • Swagger-UI version: Latest
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Fails to decode the response when it is of multipart type.

Example Swagger/OpenAPI definition:

# your YAML here
  /xyz:
    post:
      parameters:
        - in: query
          name: q
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                upfile:
                  type: string
                  format: binary
                params:
                  type: string
      responses:
        '200':
          description: OK
          content:
            multipart/form-data:
              schema:
                type: object
                properties:
                  points:
                    type: string
                  file:
                    type: string
                    format: binary
              encoding:
                points:
                  contentType: text/plain
                file:
                  contentType: application/octet-stream

Describe the bug you’re encountering

When the UI receives the response from the server where the response has multipart body, the UI doesn’t decode the message and displays the result accordingly.

Currently it shows the following error and tries to display everything as text (even the binary junk characters) and the multipart data is not split into corresponding part files.

Response body Unrecognized response type; displaying content as text.

--29c81d996c8947829f47f91a3c36aa4f
Content-Disposition: form-data; name="points"

[1,2,3,4,5]
--29c81d996c8947829f47f91a3c36aa4f
Content-Disposition: form-data; name="file"; filename="tmp1e95kj4w.nii.gz"
Content-Type: application/octet-stream

��8�\�tmp1e95kj4w.nii��$��V��0?�  7������~��08u���JI))�ʔV�8���T�[Kս�̙�����G����Ͽ����������w�������������?����5����o�5�x������/O���_���?��ϟ���?}

Expected behavior

  1. binary data part as downloadable link
  2. text/plain data part on UI screen

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

2reactions
nikhilkumarenrcommented, Jul 14, 2020

Much needed feature as API client.

0reactions
hedi-sellami-shiftcommented, Oct 6, 2022

Hi! Happy to finally find people who have the same issue 😄 Any news concerning this issue? Any workaround that we can use to display a file alongside a textbox?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I decode a multipart HTTP response? - Stack Overflow
I have an ASP.NET web application that's returning a multi-part response containing a JSON-encoded object, plus a bunch of binary files.
Read more >
Working with Multipart — aiohttp 3.8.3 documentation
Assume you made a request, as usual, and want to process the response multipart data: async with aiohttp.request(...) as resp: pass.
Read more >
Uploading and copying objects using multipart upload
Multipart upload allows you to upload a single object as a set of parts. Each part is a contiguous portion of the object's...
Read more >
Parse multipart/form-data response in salesforce
this requirement seems to be a combination of both an inbuilt class AND some manual efforts from your end! The file needs to...
Read more >
multipart/form-data fetch cannot be parsed with Response ...
One should be able to use the .formData on the result, and it should not be encoded in base64 - NOT sending the...
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