MultipartParseError: Did not find boundary character 48 at index 2 when uploading large files #452
-
I'm encountering the following error while attempting to upload files using multipart/form-data requests in the Esmerald framework I would greatly appreciate any assistance or suggestions on how to resolve this issue with file uploads exceeding 1 MB in the Esmerald framework. Thank you in advance for your time and help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Hi @prashikdewtale10 that is a new one. In order to be able to assist you, could you please provide more details in how you did implement it, like code examples please? |
Beta Was this translation helpful? Give feedback.
-
@prashikdewtale10 I literally did this: from esmerald import Esmerald, post, Body, Gatewaym UploadFile
from esmerald.enums import EncodingType
@post("/upload-file")
async def upload(data: UploadFile = Body(media_type=EncodingType.MULTI_PART)) -> dict[str, str]:
return {"name": data.filename}
app = Esmerald(
routes=[
Gateway(handler=upload),
]
) You can also do: from esmerald import Esmerald, post, File, Gatewaym UploadFile
@post("/upload-file")
async def upload(data: UploadFile = File() -> dict[str, str]:
return {"name": data.filename}
app = Esmerald(
routes=[
Gateway(handler=upload),
]
) Tested even using the OpenAPI documentation at https://localhost:8000/docs/swagger As per documentation and uploaded a 7MB file and it works. I'm not sure about your side of the implementation? Apologies for taking so long but we have been quite busy. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to implement a file upload API using the Esmerald framework. The API should accept a file and some contextual data (file_context and applicable_date) via form data submitted through Postman. Below is the current implementation: async def upload_files(
request: Request,
data: Any = Form(),
) -> Response:
# Parse form data
request_file = data.get('file')
# for validating type of file_context it should be str only
context_name = data.get("file_context")
applicable_date = data.get("applicable_date")
app = Esmerald(
routes=[
Gateway(handler=upload_files),
]
) What I'm Trying to Achieve
Issues and Questions
|
Beta Was this translation helpful? Give feedback.
@prashikdewtale10 I literally added a test proving that passes with more than 1MB, maybe something its not right on your side? Let me share an example with you: