...

/

Solution: Standardize File Storage Clients

Solution: Standardize File Storage Clients

Unify local and cloud file storage clients under a shared .upload() and .download() interface.

We'll cover the following...

Solution explanation

  • Lines 2–19: We define two incompatible clients:

    • localFs uses save() and read() for file operations.

    • s3Client uses uploadFile() and getFile().

  • Lines 22–24: The StorageAdapter constructor accepts any client instance.

    • It stores a reference to the wrapped client.

    • This enables the adapter to forward calls dynamically.

  • Lines 26–31: The .upload() method unifies upload behavior.

    • If ...