SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.16k stars 223 forks source link

Forbidden image #174

Open joaopdcgarcia opened 3 years ago

joaopdcgarcia commented 3 years ago

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
    }
dreampiggy commented 3 years ago

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 commented 3 years ago

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

joaopdcgarcia commented 3 years ago

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.