uplink
uplink copied to clipboard
Specify `filename` and `content_type` headers through `Part` annotation
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
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.