Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
How to select the disk location for UploadFile parameter in FastAPI?

I am running FastAPI application on a embedded device. The embedded device has limited resources (disk space and RAM). However, an SD card with plenty of space is available. I would like to upload and store a large file on the SD card. The FastAPI documentation suggests using UploadFile parameter.

I tried a simple application:

from fastapi import FastAPI, File, UploadFile

app = FastAPI()


@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile = File(...)):
    return {"filename": file.filename}

... and after posting a large file, I get a response with status code 400 and body {"detail": "There was an error parsing the body"}.

I was monitoring disk usage during the upload process and I saw the free space on partition /tmp was decreasing until it ran out of space. I assume FastAPI figures out that the uploaded file is too big to be stored in memory and decides to store it on disk. Unfortunately, the selected disk is also too small.

How can I select the location which FastAPI internally uses to store the uploaded file?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You could add the following to your application to change the default location of temp files (using Python's tempfile module):

import tempfile

tempfile.tempdir = "path/to/tempdir/here"
print("Temp directory after change:", tempfile.gettempdir())
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda