From eca4929d08d286320e0617f57762cfcd54b81c50 Mon Sep 17 00:00:00 2001 From: bugfix-mission Date: Thu, 23 Apr 2026 02:44:34 +0800 Subject: [PATCH] fix(docs): handle string destination in storage engine template The custom storage engine template assigned opts.destination directly to this.getDestination and then invoked it as a function, which fails when a user passes a string path (as DiskStorage already supports). Mirror DiskStorage's behavior by wrapping string destinations in a callback fn. --- StorageEngine.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/StorageEngine.md b/StorageEngine.md index 4b411ab1..831a81ea 100644 --- a/StorageEngine.md +++ b/StorageEngine.md @@ -44,7 +44,11 @@ function getDestination (req, file, cb) { } function MyCustomStorage (opts) { - this.getDestination = (opts.destination || getDestination) + if (typeof opts.destination === 'string') { + this.getDestination = function ($0, $1, cb) { cb(null, opts.destination) } + } else { + this.getDestination = (opts.destination || getDestination) + } } MyCustomStorage.prototype._handleFile = function _handleFile (req, file, cb) {