[Python] How to Upload a large File (≥3GB) to FastAPI backend?

Discussão em 'Python' iniciado por Stack, Novembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to upload a large file (≥3GB) to my FastAPI server, without loading the entire file into memory, as my server has only 2GB of free memory.

    Server side:

    async def uploadfiles(upload_file: UploadFile = File(...):


    Client side:

    m = MultipartEncoder(fields = {"upload_file":eek:pen(file_name,'rb')})
    prefix = "http://xxx:5000"
    url = "{}/v1/uploadfiles".format(prefix)
    try:
    req = requests.post(
    url,
    data=m,
    verify=False,
    )


    which returns:

    HTTP 422 {"detail":[{"loc":["body","upload_file"],"msg":"field required","type":"value_error.missing"}]}


    I am not sure what MultipartEncoder actually sends to the server, so that the request does not match. Any ideas?

    Continue reading...

Compartilhe esta Página