Cloudinary Storage adapters

Hi all,

I’m currently using a cloudinary storage adapter and I’m on Ghost 3.20.3 on a self-hosted DO droplet. I wanted to update to the latest version of Ghost but I’m unable to, as it fails because of the storage adapter not working properly…I’ve discussed this in a previous topic some time ago, but I am revisiting now as it is time to update.

In fact, in my explorations, a lot of storage adapters seem to be poorly updated or untouched. What alternatives are there out there for services like Cloudinary? What’s the best way to go with this - especially if I want to move to Ghost 4?

Thanks all

(I’ve done some searching and I can’t find out if this has been asked - sorry if I’ve missed something)

Hi all,

I’ve since managed to switch over the to the latest ghost-storage-cloudinary and the latest version of Ghost (4.21.0) however now when I try and upload images using the storage adapter, I get a red bar across the image placer that reads

“Cannot read property ‘replace’ of undefined”

Any thoughts?

Storage adapters are all community-maintained and there aren’t that many people using them, so wouldn’t be surprised if a few have fallen out of date.

Easiest thing to do, of course, would be to use Ghost’s built-in file handling. Is there anything specific you’re using Cloudinary for?

Do you know, I’ve been pondering that exact question whilst I’ve been fiddling with this.
“Why am I using Cloudinary?”
In short, I think I thought it’d be a good way to keep hosting cheap. With the traffic I get right now, I’m able to sit on then cheapest Digital Ocean tier and use the Cloudinary free tier. All that said, if I suddenly get a big peak in traffic or popularity or whatever, Cloudinary becomes very expensive very quickly, whereas I could more gently increase the provision within Digital Ocean. Maybe actually, it’ll be better to use DO and Ghost’s internal file handling. I’m not actually using transformations even, it’s just a bucket for putting pictures into.

Is there an easy way to move things from one storage provider to another? i.e. to go back to Ghost from Cloudinary, short of manually moving and editing every post?

Great question! I’m not sure - @pauldavis or @Hannah might know

@smi I do a have a WIP script that is built to scrape images and download them to Ghost’s own storage. It generates a directory of images, and a new content JSON file with updated image paths. This would solve your use-case, but it’s not quite ready to be released yet as it needs more testing.

You can either wait for that (which should be released in the next week or two–I can ping you in this thread!), or you can use the Migrate tools. It uses the Admin API to fetch the content, while also downloading & fetching the images to use Ghost’s own storage. It will attempt to fetch any image, regardless of its location or domain. The only caveat you might need to be aware of is that its built to migrate content, so it won’t bring over any settings. It will handle posts, pages, and authors. It will migrate tags themselves, but not tag images.

1 Like

Thanks @pauldavis - that WIP script sounds promising, and I’m happy to wait. And indeed be an early tester if that’d be helpful!

(Thanks also @John for the tag in of people who might know)

Appreciate all the help, thank you.

Hey @smi !

I’ve been working on a suite of tools that helps people do things in bulk. It’s called gctools, and the repo is here. :warning: Note: The whole tool is WIP and should be approached with caution!

I’ve just pushed the tool that will download images referenced in a JSON file. After cloning the repo and installing the dependencies, you’ll need to export your content as a JSON file. Settings > Labs > [Export]

When cd'ed into the project, run:

yarn dev fetch-images ./path/to/my-content.json https://mysite.com

Once complete, it will create a zip file containing all images and a JSON file that has updated image references. Upload this zip into Ghost (Settings > Labs > [Import]) and you should be good to go! Note that it will duplicate content, so if importing on top of existing content, you’ll want to delete that first (and backup before!)

As I say above, it’s WIP and I’ve only tested this using a JSON file from Ghost 4.x, but it should be absolutely fine with 3.x files too.

Let me know how you get on! :pray:

1 Like