How should custom storage adapters be returning asset URLs?

I’ve come across adapters that return absolute URLs to assets, and others that return a relative URL in the format of /content/.../<image> and also implement a CustomStorage#serve to stream the asset from the provider. Which method is officially recommended? One benefit I can see for the latter is that links won’t break if you switch providers (given that the new adapter also implements a serve method).

Also, an extension of the second part of the first question: in addition to the streaming method, is simply redirecting to the actual URL acceptable? If the goal is to simply prevent links from breaking, then it would work, no?

There’s no officially recommended way, it really depends on the adapter and what you want to achieve with it.

If you wanted to keep the urls as local content/image urls and implement streaming or proxying then as you said, that would prevent the links from being wrong if you switched adapters, but you’d have to manually handle moving all old images to the new provider, else they’d still 404. I’m not sure there’s a huge amount of benefit.

I’m also not sure redirecting would suffice, and regardless of whether you redirect, or proxy/stream the image you’re leaving some of the load on Ghost. So if the reason for using an adapter is to reduce load then it wouldn’t be worth it.

It really depends :slight_smile: