• Creates a plugin that acquires a distributed lock before executing any operation on a file-storage adapter.

    This plugin wraps all methods (reads, writes, copy/move, removal, and URL generation) with a lock acquired via ILockFactory. The lock key is derived from the file key (or source key for copy/move), ensuring that concurrent operations on the same file are serialised while operations on different files can proceed in parallel.

    By default all methods are protected. Use onlyMethods to restrict which operations are locked.

    Parameters

    • settings: WithFileStorageLockSettings

      Configuration for the lock behaviour.

      • lockFactory: ILockFactory

        A factory that creates named locks. Each lock is keyed by the file key to ensure concurrent operations on the same file are serialised while operations on different files can proceed in parallel.

      • OptionalonlyMethods?: WithFileStorageLockMethods[]

        The subset of methods to protect with a lock. When omitted, all methods except removeByPrefix are protected by default.

        [
        "exists",
        "getStream",
        "getBytes",
        "getMetaData",
        "add",
        "addStream",
        "update",
        "updateStream",
        "put",
        "putStream",
        "copy",
        "copyAndReplace",
        "move",
        "moveAndReplace",
        "removeMany",
        "getPublicUrl",
        "getSignedDownloadUrl",
        "getSignedUploadUrl",
        ]

    Returns PluginFn<Partial<IFileUrlAdapter> & IFileStorageAdapter>

    A middleware plugin that wraps an ISignedFileStorageAdapter.