SDWebImageSwiftUI icon indicating copy to clipboard operation
SDWebImageSwiftUI copied to clipboard

Forbidden image

Open joaopdcgarcia opened this issue 3 years ago • 3 comments

I'm using SDWebImageSwiftUI for the first time. And I'm getting a forbidden image. Nevertheless, since its not on the client nor on the server, it must be coming from the framework.

I'm using this in a HomeWidget extension (thus using the SwiftUI version of this framework here), to download and cache and display images in there. And also to possibly share the cache with the main app?

I have set the Authorization Bearer token in the Widget init() method and App Transport Security Security is set to allow arbitrary loads.

Any clues of what may be happening?

Also, onFailure and onSuccess don't seem to be called.

image

WebImage(url: imageURL)
                    .onFailure(perform: { (error) in
                        _ = print("Failed to download image \(track!.imageURL.absoluteString) with error \(error.localizedDescription)")
                    })
                    .onSuccess(perform: { (image, _, cache) in
                        _ = print("Succeeded to download image \(track!.imageURL.absoluteString) from cache \(cache), image \(image)")
                    })
                    .resizable()
                    .cornerRadius(5.0)
                    .frame(width: 100,
                           height: 100,
                           alignment: .center)
                    .shadow(radius: 5.0)
init() {
        // This is the best place to init configurations `HomeWidget: Widget` is the starting point for HomeWidget-Extension.
        SDWebImageDownloader.shared.setValue("Bearer \(HomeWidget.imageServerSecret)", forHTTPHeaderField: "Authorization")
        SDWebImagePrefetcher.shared.maxConcurrentPrefetchCount = 6
        SDImageCache.shared.config.diskCacheReadingOptions = NSData.ReadingOptions.mappedIfSafe
        SDImageCache.shared.config.maxMemoryCount = 40 // 40 Images in memory max
        SDImageCache.shared.config.maxDiskAge = 7884000 // Three months
    }

joaopdcgarcia avatar Mar 02 '21 15:03 joaopdcgarcia

Nevertheless, since its not on the client nor on the server, it must be coming from the framework.

This framework does not provide or bundle any image assets. This is open source project, you can investigate anything.

I think this is something from Apple's SwiftUI framework itself ? Or the System symbol image. You can use the Xcode View Debugger to find the description of that image to see what it is.

dreampiggy avatar Mar 03 '21 03:03 dreampiggy

App Group Sharing: https://github.com/SDWebImage/SDWebImage/issues/3022 https://github.com/SDWebImage/SDWebImage/pull/3066

dreampiggy avatar Mar 03 '21 03:03 dreampiggy

so the issue is that HomeWidgets don't allow async downloads. So I have to download the image first, store it on disk in a shared container path and only display it then, synchronously.

joaopdcgarcia avatar Mar 03 '21 08:03 joaopdcgarcia