Skip to content

Suggestion: Expose outStream in _handleFile to allow manual stream cleanup on request abort #1300

@1716247670

Description

@1716247670

In custom diskStorage implementations using multer, when a client upload request is aborted (e.g. user cancels or network error), developers often want to manually destroy the fs.createWriteStream in req.on('aborted') to ensure the file handle is released.

On Windows, failing to properly close the stream can prevent the file from being deleted due to locked handles.

Currently, outStream is a local variable inside _handleFile and is not accessible from outside, making it impossible to call .end() manually.

Suggestion: Please consider exposing the stream via file.streamOut = outStream, so developers can manually call end() in req.on('aborted') or similar logic. This would greatly improve control in handling incomplete uploads, especially for chunked or large file uploads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions