Skip to content

TryGhost/Ghost-Storage-Base

Repository files navigation

Ghost Storage Base

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

Install

pnpm add ghost-storage-base

Usage

Extend 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.

Development

Testing

  • pnpm test to run tests
  • pnpm lint to run linting

Publish

  • pnpm ship

Copyright & License

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.

About

Base storage adapter for Ghost

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors