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

This looks awesome. Do you plan to add a web interface? I’m new to ghost and not great on Linux. I tried the CLI version but was not able to get it working. I could not tell if I should git clone to /current /content or /ghost or another spot. I finally chose /content but when I ran cgtools nothing happened, “cgtools: command not found.” I looks like yarn worked. Stuck here. Thanks for your work on this.

success Registered "gctools".

Hello @pauldavis! It’s been a while - over a year - but here I am actually doing this thing!
Sorry it’s been so long and sorry I never replied to let you know how I got on. Here’s how it went…

I had lots of upgrade/update issues, so it took a lot of fiddling with node before anything worked. I ended up with a 500mb zip file with all the images and a .JSON file. This was obviously way too big to push onto the importer, so I ended up having to FTP the images up.
The JSON file doesn’t seem to change anything, though - the posts all still have the old references.

Am I doing something wrong by just putting it through the importer?

Long story long - the gctools all worked fine (although it was fetch-assets and not fetch-images - I guess it had changed since you posted!) and I think I’m most of the way there now.

Hi! The fetch-assets tool should create a file called ghost-import-correct-assets.json, as well as the content folders. I just did a local test and it worked just fine, but different URLs may cause issues.

I’m going to spend some time next week updating gctools, with a special focus on the asset scraper. Would you be able to send me a couple of URLs of images stored on Cloudinary in a private message on here? I can use them to test & verify they’re handled correctly.