You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following to be able to upload a .tar.gz file. @post("/upload", media_type="application/x-gtar") async def upload(self, data: Annotated[UploadFile, Body(media_type=RequestEncodingType.MULTI_PART)] ) -> dict[str, Any]: return { "File Name": data.filename, "Content Type": data.content_type, "Headers": data.headers }
However, I keep getting 500 internal server errors. Am I implementing this correctly?
media_type is used to serialize whatever you return from the handler upload. Litestar does not know how to serialize dict[str, Any] into a tar file which is why it fails.
media_type is not used to indicate that your route accepts tar gz files.
You can remove media_type and you will notice that you can indeed upload a file and get a json response
media_type is used to serialize whatever you return from the handler upload. Litestar does not know how to serialize dict[str, Any] into a tar file which is why it fails.
media_type is not used to indicate that your route accepts tar gz files.
You can remove media_type and you will notice that you can indeed upload a file and get a json response
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
media_typeis used to serialize whatever you return from the handlerupload. Litestar does not know how to serializedict[str, Any]into a tar file which is why it fails.media_typeis not used to indicate that your route accepts tar gz files.You can remove
media_typeand you will notice that you can indeed upload a file and get a json response