RFC-7578 - Need API to communicate to expect a file #2707
YStrauchP4
started this conversation in
General
Replies: 1 comment
-
See related issue/discussion in the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have this stack:
R
client ->curl
-> FastAPI -> Scarlette.The client (curl for R) does not allow adding a file name for in-memory uploads. Technically they are correct as RFC-7578 says for this use case, file names are allowed to be omitted:
So from their perspective, there should not be a need to add a name from their perspective.
Scarlette docs says:
I understand the need to somehow distinguish a file upload from a string. But this deliberately ignores what RFC-7578: 4.2 specifies and breaks compatibility with official clients.
FastAPI on the other hand knows that I expect a file because I annotated the parameter. It doesn't have a mechanism to communicate this to Scarlette though, Scarlette guesses the type incorrectly, and it gets rejected by FastAPI (pydantic probably).
I am not deep in the design patterns between FastAPI and Scarlette, but to me it seems that Scarlette needs a way of FastAPI to tell it to expect a file. Is that feasible?
There's another discussion on the FastAPI GitHub where this was raised:
fastapi/fastapi#11822
Beta Was this translation helpful? Give feedback.
All reactions