Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda