Base class for Ghost storage adapters. Provides the shared helpers (target directory by year/month, filename sanitization, unique-filename generation) that custom storage adapters build on, and declares the interface (exists, save, serve, delete, read) that Ghost expects every adapter to implement.
Docs: https://ghost.org/docs/config/#creating-a-custom-storage-adapter
pnpm add ghost-storage-baseExtend StorageBase and implement the five required methods. The base class supplies getTargetDir, getSanitizedFileName, generateUnique, and getUniqueFileName for you.
const StorageBase = require('ghost-storage-base');
class MyStorage extends StorageBase {
exists(filename, targetDir) { /* ... */ }
save(file, targetDir) { /* ... */ }
serve() { /* ... */ }
delete(filename, targetDir) { /* ... */ }
read(options) { /* ... */ }
}
module.exports = MyStorage;generateUnique and getUniqueFileName call this.exists(...), so exists must return a Promise<boolean> for them to work.
pnpm testto run testspnpm lintto run linting
pnpm ship
Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license. Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our trademark policy for info on acceptable usage.