Maybe I could make a custom RemoteImageView and change it so that url string that it takes is just the image's base path and the RemoteImageView does the work of concatenating the current image path with the constants (prefix, infix, suffix)?
UPDATE 1:
I tried that idea, changing the RemoteImageView ( original version of which is here: https://www.hackingwithswift.com/forums/swiftui/loading-images/3292/6902 ) but got other errors (noted below).
Here's the change I attempted:
private class Loader: ObservableObject {
var data = Data()
var state = LoadState.loading
let thumbnailPrefix = "https://my-subhost-at.amazonaws.com/" // NOTE: not actual URL
let thumbnailInfix = "/thumbs-"
let thumbnailSuffix = "-00001.jpg"
init(url: String) {
guard let parsedURL = URL(string: (thumbnailPrefix + url + thumbnailInfix + url + thumbnailSuffix)) else {
fatalError("Invalid URL: \(url)")
}
...
I also tried this:
guard let parsedURL = URL(string: String(thumbnailPrefix + url + thumbnailInfix + url + thumbnailSuffix))
In conjunction with changing my original call to RemoteImageView(url: image.url).
Here's the error:
NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDataTask <F5CAD68F-C4BF-474E-84F6-C910D5D27431>.<89>"), NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <F5CAD68F-C4BF-474E-84F6-C910D5D27431>.<89>, NSUnderlyingError=0x600001ca2c10 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}}*
UPDATE 2:
Ooops! My original code attempt actually worked (i.e., concatenating in the call, not customizing RemoveImageView). The problem was that I had fetched a JSON recordset from one server but was constructing the URL path that included a different subdomain on that server. Once I corrected the thumbnailPrefix constant, the remove images appeared. Uggh.