Search code examples
iosuiimageviewuiimagesdwebimage

Unable to download an image with double extension (.jpg.png)


I have a problem with the download of this image:

http://images.cubovision.it/vod/Film/2015/01/CUBOMOBILE_SCROLL_90003165.jpg

from the web by using SDWebImage, but I get the same result if manually try to download it using synchronously with NSURL and NSData. The error I get is:

NSURLErrorDomain Code=404

and it only happens when I try to download the image inside my application, if I try to view it from the web browser, Safari for both iOS and OS X the image is viewable and downloadable. If I try to download the image from the computer the image file has two extensions, though, both .JPG and .PNG

Name of the file:

CUBOMOBILE_SCROLL_90003165.jpg.png

How can I solve this problem?

This is the code I currently use to download the image:

NSURL+NSDATA:

NSURL *url = [NSURL URLWithString:@"http://images.cubovision.it/vod/Film/2015/01/CUBOMOBILE_SCROLL_90003165.jpg"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]]; 
[self.view addSubview:[[UIImageView alloc] initWithImage:image]];

SDWebImage:

[self.purchaseCoverImage sd_setImageWithURL:[NSURL URLWithString:@"http://images.cubovision.it/vod/Film/2015/01/CUBOMOBILE_SCROLL_90003165.jpg"]
                               placeholderImage:[UIImage imageNamed:@"itemCollectionPlaceholder"]
                                        options:SDWebImageCacheMemoryOnly
                                      completed:nil];

Solution

  • I ended up saving a local copy of the image, with the .jpg extension only, luckly enough this is only a placeholder image, but the bug still remains. I think it's due to the way iOS/SDWebImabe/NSURL read URL Links