upload_state_store

The `upload_state_store` directive configures the temporary storage method for upload session states during file uploads in NGINX.

Syntaxupload_state_store path [session_id] [options];
Defaultnone
Contexthttp, server, location
Arguments1-4

Description

The upload_state_store directive is part of the NGINX upload module which handles file uploads using the multipart/form-data encoding standard. This directive specifies how the state of an upload session is stored, allowing for resumable uploads. It accepts up to four arguments, which can be a path for saving state information, a session identifier, and optional configurations for handling errors or specific states. When set, it tracks the ongoing upload process and ensures that if an upload is interrupted, it can be resumed from the last known state instead of starting over. This is particularly useful for large files or unreliable network conditions where interruptions are possible.

When an upload operation starts, its session state is maintained in temporary files as specified by the directive. The uploaded files and their respective states are stored securely and can be retrieved later, enabling a seamless user experience. Additionally, proper error handling is implemented, allowing for graceful recovery from interruptions. This helps to manage resources effectively and ensures that uploads complete successfully even in suboptimal conditions, thus enhancing the robustness of file upload functionalities in applications using NGINX.

Config Example

location /upload {
    upload_pass /process;
    upload_state_store /tmp/upload_states;
    # Optional: specify session ID and additional options
    upload_state_store /tmp/upload_states $session_id; 
}

Ensure the path provided has appropriate write permissions for the NGINX user.

Using incorrect session IDs can lead to upload failures or data loss.

The storage path must support concurrent write access to handle multiple uploads.

← Back to all directives