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

327
Vistas
Nginx Upload Module for Django REST framework

I want to upload large files to my djangos MEDIA folder using the nginx upload module.

The Django REST "POST" endpoint for the single file upload is at

http://localhost:1337/api/record/measurements/#id/upload/

where #id can be an integer (1,2,3,4,5...), and works for django without nginx.

I wrote the nginx config

    #/etc/nginx/conf.d/default.conf
    location @backend {
        proxy_pass http://django-app:8000;
    }

    location  /api/record/measurements/1/upload/ {
        error_page 418 = @upload;
        if ($request_method = POST ) {
            return 418;
        }
        include /etc/nginx/mainloc.conf;
    }

    location @upload {
        upload_pass   @backend;
        upload_store /vol/web/media/_upload 1;
        upload_store_access user:r;
        upload_set_form_field $upload_field_name.name "$upload_file_name";
        upload_set_form_field $upload_field_name.content_type "$upload_content_type";
        upload_set_form_field $upload_field_name.path "$upload_tmp_path";
        upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
        upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
        upload_pass_form_field "^submit$|^description$";
        upload_cleanup 400 404 499 500-505;

    }


    location / {
        include /etc/nginx/mainloc.conf;
    }

with

#mainloc.conf
proxy_pass http://django-app:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

Edit:

I managed to upload the file to /vol/web/media/_upload, but after the file upload is complete, I get the response

{
    "id": 1,
    "data": null
}

and the uploaded File is not moved to the final location MEDIA=/vol/web/media/ but remains in upload_store

over 4 years ago · Santiago Trujillo
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