npm install ghost-storage-adapter-oracle-ords
https://www.npmjs.com/package/ghost-storage-adapter-oracle-ords
https://github.com/lengerrong/ghost-storage-adapter-oracle-ords#readme
In my last post, how to custom storage adapters to make your self-hosted Ghost instance filesystem completely external?, I had a plan to implement a storage adapter of Ghost for Oracle Cloud Autonomous JSON Databases to leverage the always free 40Gb space provided by Oracle Cloud.
After researched Oracle ORDS REST API, I implement a orcal-ords-client lib to encapsulate the REST APIs for easy usage. Then I developed this storage adapter based on the orcal-ords-client lib.
Core Idea
putJSONDocument(alias: string, json: JSONValue): Promise<Item>;
deleteJSONObject(alias: string, id: string): Promise<boolean>;
queryJSONDocument(alias: string, query: any, payload: any): Promise<Collection>;
We are able to implement the required methods to custom the storage adapter.
delete: first use queryJSONDocument to find the id
of the image stored by path, and then delete the image via deleteJSONObject
exists: use queryJSONDocument to find the image stored by path
save: construct the JSON object and save into database via putJSONDocument
serve: use queryJSONDocument to find the image stored by path and then
pipe the Buffer content to response stream
read: |
use queryJSONDocument to find the image stored by path and
return the Buffer from the blob field.
Ghost Configuration
"storage": { "active": "OracleImagesStorage", "OracleImagesStorage": { "oauthClients": [ { "client_id": "YOUR_ORACLE_AUTONOMOUS_JSON_DATABASE_OAUTH_CLIENT_ID", "client_secret": "YOUR_ORACLE_AUTONOMOUS_JSON_DATABASE_OAUTH_CLIENT_SECRET", "schema": "YOUR_ORACLE_AUTONOMOUS_JSON_DATABASE_USER", "ords_url": "YOUR_ORACLE_AUTONOMOUS_JSON_DATABASE_ORDS_URL", "alias": "YOUR_ORACLE_AUTONOMOUS_JSON_DATABASE_COLLECTION_NAME" }, ] } }
You can put multiple Oracle Cloud Autonomous JSON Databases clients in the above.
You can get 40Gb free space to use per account. if you have 10 Oracle Cloud account,
You can use 400Gb free space.:)
Use this adapter in your Ghost
In my another blog(https://errong.win) hosted on free Google Computer Engine,It is a self hosted Ghost instance. The below photo is served with path startingwith /content/images/, but you can't any images under the /content/images directoryon my GCP vm's local file system.
No comments:
Post a Comment