From 151ab6968c1cc79e3f94463d248ef4948840f5d3 Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 8 Nov 2021 11:29:33 +0400 Subject: [PATCH] Added local file storage adapter refs https://github.com/TryGhost/Toolbox/issues/114 - This adapter is meant to power Files API - The files will be stored under `/files/` in the configured content path and under `/content/files/` URL. --- .../server/adapters/storage/LocalFilesStorage.js | 16 ++++++++++++++++ core/shared/config/defaults.json | 4 +++- core/shared/config/helpers.js | 2 ++ package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 core/server/adapters/storage/LocalFilesStorage.js diff --git a/core/server/adapters/storage/LocalFilesStorage.js b/core/server/adapters/storage/LocalFilesStorage.js new file mode 100644 index 0000000000..4797c77d3f --- /dev/null +++ b/core/server/adapters/storage/LocalFilesStorage.js @@ -0,0 +1,16 @@ +// # Local File System Video Storage module +// The (default) module for storing media, using the local file system +const config = require('../../../shared/config'); +const constants = require('@tryghost/constants'); +const LocalStorageBase = require('./LocalStorageBase'); + +class LocalFilesStorage extends LocalStorageBase { + constructor() { + super({ + storagePath: config.getContentPath('files'), + staticFileURLPrefix: constants.STATIC_FILES_URL_PREFIX + }); + } +} + +module.exports = LocalFilesStorage; diff --git a/core/shared/config/defaults.json b/core/shared/config/defaults.json index 58b9ce5c0a..39c502fbba 100644 --- a/core/shared/config/defaults.json +++ b/core/shared/config/defaults.json @@ -25,7 +25,9 @@ "storage": { "active": "LocalImagesStorage", "media": "LocalMediaStorage", - "LocalMediaStorage": {} + "files": "LocalFilesStorage", + "LocalMediaStorage": {}, + "LocalFilesStorage": {} }, "scheduling": { "active": "SchedulingDefault" diff --git a/core/shared/config/helpers.js b/core/shared/config/helpers.js index a1dd04817b..44e8a1e665 100644 --- a/core/shared/config/helpers.js +++ b/core/shared/config/helpers.js @@ -34,6 +34,8 @@ const getContentPath = function getContentPath(type) { return path.join(this.get('paths:contentPath'), 'images/'); case 'media': return path.join(this.get('paths:contentPath'), 'media/'); + case 'files': + return path.join(this.get('paths:contentPath'), 'files/'); case 'themes': return path.join(this.get('paths:contentPath'), 'themes/'); case 'adapters': diff --git a/package.json b/package.json index 2cef607704..d7a2929bc0 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@tryghost/bootstrap-socket": "0.2.13", "@tryghost/color-utils": "0.1.2", "@tryghost/config-url-helpers": "0.1.3", - "@tryghost/constants": "0.1.12", + "@tryghost/constants": "1.0.0", "@tryghost/custom-theme-settings-service": "0.3.1", "@tryghost/debug": "0.1.9", "@tryghost/email-analytics-provider-mailgun": "1.0.5", diff --git a/yarn.lock b/yarn.lock index f0cbb8d318..20b6c512a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1335,10 +1335,10 @@ resolved "https://registry.yarnpkg.com/@tryghost/config-url-helpers/-/config-url-helpers-0.1.3.tgz#42c88bbfe343d55595aa27b25665b87cb9cbaa23" integrity sha512-+Ob3QTLxxpV4VBNEG/6Veop5MLxKlpPkGtnuRO/0PNaxm77Xo6TdLYAqUL+SnHSYRySr3lkLZCZUa9e6HhECbg== -"@tryghost/constants@0.1.12": - version "0.1.12" - resolved "https://registry.yarnpkg.com/@tryghost/constants/-/constants-0.1.12.tgz#17efd5dbb5d0bfbf11de1ceaaed347d165e63b1f" - integrity sha512-nQPov2XnfnWxMf330JVLRGUJUqupgvBGWrUU31GJYQRTheKS0N6DSBCKJaO0euGEsWfvJ+BsWVbAJp0vxsUDzg== +"@tryghost/constants@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@tryghost/constants/-/constants-1.0.0.tgz#63ceeb4614e4e79bf208b79664c5898334b00a5f" + integrity sha512-vbJFj/jhPockvcjf3prBTj9YD9aeIWu2rK9Y0rXNQDA2RslTh9m8Y7NO2JzQ+kG2n1yOJRqdcgNJCXwwS/CjoA== "@tryghost/custom-theme-settings-service@0.3.1": version "0.3.1"