D.D.
D.D.

Reputation: 491

SDWebImage says "URL not found" although it exists

I want to download an image from the web and set it as marker icon on a map. For downloading I am using the SDWebImage library. Unfortunatly I always get an error that says:

The requested URL was not found on this server.

But the URL exists. I tried different image URLs, everyone can be opened in the browser but I get always the same error.

This is my code:

let url=NSURL(fileURLWithPath:"http://blogs.taz.de/arabesken/files/2012/05/testbild-sendepause-300x240.jpg")

var managerCompletedBlock:(UIImage!, NSError!,SDImageCacheType,Bool) -> Void = {
                      image,error,cacheType,finished in
                      if(finished){
                            if let s = error.localizedDescription
                            {
                                 println(s)
                            }
                       }
      }
var imgManager:SDWebImageManager = SDWebImageManager.sharedManager()
imgManager.downloadWithURL(url, options: SDWebImageOptions.HighPriority, progress: nil, completed: managerCompletedBlock)

I have internet connection (API calls are working) and the URL exists. Furthermore the code works as intended if I use an File Path instead of an Web URL.

Does anybody have an idea what's the problem?

Upvotes: 2

Views: 1089

Answers (1)

Midhun MP
Midhun MP

Reputation: 107121

Issue is with this code:

let url=NSURL(fileURLWithPath:"http://blogs.taz.de/arabesken/files/2012/05/testbild-sendepause-300x240.jpg")

Change that to:

let url=NSURL(string:"http://blogs.taz.de/arabesken/files/2012/05/testbild-sendepause-300x240.jpg")

We use fileURLWithPath for local file paths not for web urls.

Upvotes: 9

Related Questions