-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to extend adapter? #70
Comments
You can extend the Storage by extending the public API. But then you would have to implement the new features that you've added to the local adapter to all other adapters as well otherwise you break the abstraction layer which is the main feature and "raison d'être" of this library. What you can do to use the functionality that you've added to AdapterLocal is: const configuration = {
type: StorageType.LOCAL,
directory: "path/to/directory",
};
const storage = new Storage(configuration);
const adapter = storage.getAdapter() as AdapterLocal;
adapter.yourMethod();
// or:
(storage.adapter as AdapterLocal).yourMethod(); |
Alternately you could use the adapter stand-alone: const configuration = {
type: StorageType.LOCAL,
directory: "path/to/directory",
};
const adapter = new AdapterLocal();
adapter.yourMethod(); You can use the full API on an adapter instance directly. You'd only be missing |
You can extend the protected method |
But then I'd lose the storage abstraction, with callers needing to handle the different storage backends. What I was hoping was to override the |
I have extended
AdapterLocal
to add a method to generate public URLs.However, there is no convenient way to use this adapter with the Storage class that I can see.
There's a few ways I can think of to make this work, but the easiest might simply be to make
_adapter
protected. Let me know your thoughtsThe text was updated successfully, but these errors were encountered: