upload_progress_template

The `upload_progress_template` directive defines a template for reporting upload progress data in NGINX.

Syntaxupload_progress_template ;
Defaultnone
Contexthttp, server, location
Arguments2

Description

The upload_progress_template directive is part of the NGINX upload progress tracking module, which allows users to monitor the progress of file uploads handled by the server. This directive sets a template for the response that is returned to the client when querying the upload progress. It takes two arguments: the template string and a specification of the variables to be included in the report. The template can be customized to output data in different formats, such as JSON, plain text, or any other string format as required by the client.

This directive should be used in conjunction with the track_uploads directive, which enables the upload tracking functionality at a specified location. When a client makes a POST request to the server, NGINX tracks the upload progress and updates the corresponding template with real-time data regarding the upload status. The variables included in the template allow developers to display specific information, such as uploaded file size and status messages, based on their requirements.

The upload_progress_template directive is beneficial for creating dynamic user interfaces that need to display upload progress in a visually appealing manner, aligning with modern web standards. Proper implementation involves ensuring that the specified template accurately reflects the progress data captured by the upload tracking module, which can be thoroughly customized for various applications.

Config Example

location /upload {
    upload_progress zone_name 1m;
    track_uploads zone_name 60s;
    upload_progress_template "{ "size": "$size", "status": "$status" }" ;
}

Ensure that the template is correctly formatted to prevent errors when rendering the response.

The variables used in the template must match those available in the upload progress context.

Invalid template syntax can lead to failure in progress reporting.

← Back to all directives