I am facing problem with downloading a .jpg image using a shorted URL like this one:
shorted URL:- https://db.tt/KH5NgfT1
I got successfully NSData
length of 41791 bytes. But problem is when I convert this NSData to UIImage it gives NULL and when this NULL image I am posting on faceBook It successfully posted to my facebook account, for post on facebook I am using SLComposeViewController
and one thing more that is this Image is also not shown in SLComposeViewController
.
I am using this code for download image
NSData *downloadedImageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:shortedURL]];
Convert to UIImage
UIImage *image=[UIImage imageWithData:downloadedImageData];
returns NULL image
and My SLComposeViewController
look like this
My SLComposeViewController screenshot
I want to show downloaded image in SLComposeViewController
NO erkanyildiz maybe your above answer is wrong because there is no difference between long and shorted URL they both redirect me to a image once look at this
this shorted url not works because it's from DropBox
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://db.tt/KH5NgfT1"] options:NSDataReadingUncached error:&error];
UIImage *downloadedImage=[UIImage imageWithData:imageData];
this shorted url works because it's NOT from DropBox
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://goo.gl/FTh7No"] options:NSDataReadingUncached error:&error];
UIImage *downloadedImage=[UIImage imageWithData:imageData];
this long url not works because it's from DropBox
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://www.dropbox.com/s/5443wq99wu9a0bu/IMG_3679.PNG"] options:NSDataReadingUncached error:&error];
UIImage *downloadedImage=[UIImage imageWithData:imageData];
this long url works because it's NOT from DropBox
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.wired.com/wiredenterprise/wp-content/uploads/2013/07/20130627-DROPBOX-OFFICE-147edit.jpg"] options:NSDataReadingUncached error:&error];
UIImage *downloadedImage=[UIImage imageWithData:imageData];
So, finally I think the problem is at DropBox server may be they have some kind of web-encription so that we can't download image directly using NSData dataWithContentsOfURL: and may be because of web-encription it support to Facebook.
solution is DropBox provides api for downloading image https://api-content.dropbox.com/1/files//
DropBox Core API Documentation
Thanks for Replying