Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify `filename` and `content_type` headers through `Part` annotation #178

Open
prkumar opened this issue Oct 12, 2019 · 1 comment
Open

Specify `filename` and `content_type` headers through `Part` annotation #178

prkumar opened this issue Oct 12, 2019 · 1 comment

Comments

@prkumar
Copy link
Owner

@prkumar prkumar commented Oct 12, 2019

Is your feature request related to a problem? Please describe.
Related to a problem surfaced by @Shanoir on Gitter.

Describe the solution you'd like
I think that it would be a good idea for us to let users set the filename and content-type headers through the Part annotation. Maybe like so:

    @multipart
    @retry(when=raises(Exception) | status(400),backoff=fixed(4),stop=after_attempt(3))
    @headers(headersCollector)
    @post("api/v1/data/file-upload")
    def uploadFile(self, file: Part(filename="data.edl", content_type="application/octet-stream"), serialNumber: Field, append: Field): pass
@leiserfg
Copy link

@leiserfg leiserfg commented Oct 14, 2019

You can pass it if you use the Part as a tuple (at least with request as backend) like:

client.upload(field_name=('data.json', data))

a new implementation should not break that behavior (at least without providing a workaround) because there are APIs that expect a meaningful filename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.