marshmallow-code / marshmallow-code/flask-smorest

Multipart response

Open
#402 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
717
Forks
77
Avg merge
7h 49m
Merged PRs (30d)
3

Description

Hi!

I achieved multipart request and i was wondering if there is a way to have a multipart response.

The following code does not work for multipart response.
```
class Metadata(Schema):
meta1 = fields.Str(required=True)
meta2 = fields.Str(required=True)
meta3 = fields.Str(required=True)

class FileUpload(Schema):
file = Upload()

class MultipartResponse(Schema):
field1= fields.Str(required=True)
field2 = fields.Str(required=True)
field3 = fields.Str(required=True)
field4 = fields.Str(required=True)
file = Upload()


@classmethod
@EdcBlp.route("/filetransfer")
class FileTransfer(MethodView):

@classmethod
@EdcBlp.response(200,MultipartResponse(), content_type="multipart/form-data")
def get(cls):
pass

@classmethod
@EdcBlp.arguments(Metadata(), location="query")
@EdcBlp.arguments(FileUpload(), location="files")
def post(cls):
pass
```

Contributor guide

Open the contributing guide

Research direction

Start at the @EdcBlp.response decorator and the MultipartResponse schema shown in the issue, then trace how the GET handler builds responses when content_type is multipart/form-data. Check the existing response-handling tests and document or test the supported behavior for returning fields together with a file.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.