Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

325
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!