Giter Site home page Giter Site logo

ghost-webdav-storage-adapter's Introduction

WebDAV storage adapter for Ghost

A WebDAV storage adapter for the Ghost publishing platform 3.x

npm Version npm Downloads Build Status Dependency Status Open Issues

Installation

npm install ghost-webdav-storage-adapter
mkdir -p ./content/adapters/storage/webdav
cp -v ./node_modules/ghost-webdav-storage-adapter/dist/*.js ./content/adapters/storage/webdav

Configuration

Configure the WebDAV storage adapter by adding the following lines to the Ghost config file.

{
  "storage": {
    "active": "webdav",
    "webdav": {
      "url": "URL_TO_YOUR_WEBDAV_SERVER",
      "username": "YOUR_WEBDAV_USERNAME",
      "password": "YOUR_WEBDAV_PASSWORD",
      "pathPrefix": "YOUR_PATH_PREFIX",
      "storagePathPrefix": "YOUR_STORAGE_PATH_PREFIX"
    }
  }
}

NOTE: username, password, pathPrefix and storagePathPrefix are all optional.

The username and password configuration parameters are used in the Basic Auth access authentication on the WebDAV server.

Use a pathPrefix if you prefer to limit access to the WebDAV server to a subtree. E.g. with a pathPrefix of /ghost all files will be stored under /ghost and the adapter won't allow access to anything on the WebDAV server outside of /ghost.

This adapter returns relative URLs for uploaded files. Requests to retrieve the file will be handled by Ghost as if they are stored on a local file system. This requires the returned URLs to start with the same prefix as Ghost's local storage adapter: /content/images. This is the default value for storagePathPrefix but you can provide a different prefix. Don't forget to create a Ghost route that routes requests for the prefix to the images store.

Via environment variables

Alternatively, you can configure the WebDAV storage adapter by setting the following environment variables:

WEBDAV_SERVER_URL
WEBDAV_USERNAME // optional
WEBDAV_PASSWORD // optional
WEBDAV_PATH_PREFIX // optional
WEBDAV_STORAGE_PATH_PREFIX // optional

Debugging

To debug the WebDAV storage adapter you can set environment variable DEBUG to webdav so that the adapter will log debug messages to standard out.

License

ISC

ghost-webdav-storage-adapter's People

Contributors

bartt avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gust4ng

ghost-webdav-storage-adapter's Issues

401 Unauthorized with OneDrive

I am trying to use this adapter with OneDrive, but I am struggling with a 401 Unauthorized error. I am able to login fine with WebDav and create folders, etc. using my PC, so my settings are good. I created /ghost-assets/ and also created 2019/09 folders when I thought maybe the adapter wasn't able to create them. Nothing is getting me past it. Is this an issue specific to OneDrive/Webdav?

My config file looks like this:
"storage": {
"active": "webdav",
"webdav": {
"url": "https://d.docs.live.net/my_CID/",
"username": "[email protected]",
"password": "xxxxx",
"pathPrefix": "/ghost-assets/",
"storagePathPrefix": ""
}
}

Did a DEBUG=* ghost run to get the output:

webdav save - /ghost-assets/2019/09 - {"fieldname":"file","originalname":"IMG_5602 - IMG_5605.jpg","encoding":"7bit","mimetype":"image/jpeg","destination":"/tmp","filename":"a3d8d728dabd02e1578c0b6998f 267f2","path":"/tmp/a3d8d728dabd02e1578c0b6998f267f2_processed","size":3516905,"name":"IMG_5602 - IMG_5605.jpg","type":"image/jpeg","ext":".jpg"} +0ms
webdav exists - /ghost-assets/2019/09/IMG_5602---IMG_5605.jpg +1ms
webdav ensureDir_ - /ghost-assets/2019/09 - 2019,09 +11ms
webdav exists - /ghost-assets/2019 +0ms
webdav save - /ghost-assets/2019/09 - {"fieldname":"file","originalname":"IMG_5602 - IMG_5605.jpg","encoding":"7bit","mimetype":"image/jpeg","destination":"/tmp","filename":"a3d8d728dabd02e1578c0b6998f 267f2","path":"/tmp/a3d8d728dabd02e1578c0b6998f267f2","size":3516905,"name":"IMG_5602 - IMG_5605_o.jpg","type":"image/jpeg","ext":".jpg"} +1ms
webdav exists - /ghost-assets/2019/09/IMG_5602---IMG_5605_o.jpg +1ms
webdav ensureDir_ - /ghost-assets/2019/09 - 2019,09 +0ms
webdav exists - /ghost-assets/2019 +0ms
webdav exists - /ghost-assets/2019/09/IMG_5602---IMG_5605.jpg: false +86ms
webdav exists - /ghost-assets/2019/09/IMG_5602---IMG_5605_o.jpg: false +1ms
webdav exists - /ghost-assets/2019: false +3ms
webdav ensureDir_ - /ghost-assets/2019: Error: Invalid response: 401 Unauthorized +68ms
webdav save - /ghost-assets/2019/09 - {"fieldname":"file","originalname":"IMG_5602 - IMG_5605.jpg","encoding":"7bit","mimetype":"image/jpeg","destination":"/tmp","filename":"a3d8d728dabd02e1578c0b6998f 267f2","path":"/tmp/a3d8d728dabd02e1578c0b6998f267f2_processed","size":3516905,"name":"IMG_5602 - IMG_5605.jpg","type":"image/jpeg","ext":".jpg"}: Error: Invalid response: 401 Unauthorized +0ms
express:router : /ghost/api/canary/admin/images/upload/ +400ms
express:router : /ghost/api/canary/admin/images/upload/ +1ms
ghost:error-handler Error: Invalid response: 401 Unauthorized
ghost:error-handler at handleResponseCode (/var/www/ghost/versions/2.31.0/node_modules/webdav/dist/response.js:7:15)
ghost:error-handler at tryCatcher (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/util.js:16:23)
ghost:error-handler at Promise._settlePromiseFromHandler (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/promise.js:517:31)
ghost:error-handler at Promise._settlePromise (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/promise.js:574:18)
ghost:error-handler at Promise._settlePromise0 (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/promise.js:619:10)
ghost:error-handler at Promise._settlePromises (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/promise.js:699:18)
ghost:error-handler at _drainQueueStep (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/async.js:138:12)
ghost:error-handler at _drainQueue (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/async.js:131:9)
ghost:error-handler at Async._drainQueues (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/async.js:147:5)
ghost:error-handler at Immediate.Async.drainQueues [as _onImmediate] (/var/www/ghost/versions/2.31.0/node_modules/bluebird/js/release/async.js:17:14)
ghost:error-handler at runCallback (timers.js:705:18)
ghost:error-handler at tryOnImmediate (timers.js:676:5)
ghost:error-handler at processImmediate (timers.js:658:5)
ghost:error-handler at process.topLevelDomainCallback (domain.js:126:23) +0ms
express:router : /ghost/api/canary/admin/images/upload/ +1ms
compression no compression: size below threshold +4s
[2019-09-20 03:46:01] ERROR "POST /ghost/api/canary/admin/images/upload/" 500 407ms

Invalid response: 401 Unauthorized

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.