1

I am using sd web image and facing problem in getting image from back4app.com (parse server). I have use below code with in main thread and without main thread. And also try with encoding and without encoding. I am getting another image from different url but from back4app.com not loading.

NSString *sttt2=flel.url;
NSString *str = [[NSString alloc] initWithUTF8String:[sttt2 cStringUsingEncoding:NSUTF8StringEncoding]];

NSURL *url2 = [NSURL URLWithString:str];
dispatch_async(dispatch_get_main_queue(), ^{

        [immg1 sd_setImageWithURL:url2  placeholderImage:[UIImage imageNamed:@"profilemain_blu"]];
            });
aafat
  • 148
  • 2
  • 19
  • 1
    are you seeing the placeholder image ? Put a breakpoint in the setImageWithURL method and see what's happening there. – Teja Nandamuri Oct 13 '16 at 15:18
  • image not downloading – aafat Oct 13 '16 at 15:36
  • can u post the actual url ? – Teja Nandamuri Oct 13 '16 at 15:59
  • Try `NSData *data = [NSData dataWithContentOfURL:ulr2]`, Is `data` nil in this case? If not, if then you do `UIImage *image = [UIImage imageWithData:data];`, is `image` nil? – Larme Oct 13 '16 at 18:08
  • In nsdata case it returns nil – aafat Oct 13 '16 at 18:34
  • Is `url2` nil? If `data` is `nil`, the issue is somewhere else, because your image is not available, nothing to do with `SDWebImage`, a server issue? Can you reach the image with the URL in a web browser? Do you need to add credential (password, tokens, etc.)? – Larme Oct 13 '16 at 18:37
  • https://parsefiles.back4app.com/PSzewrOeJEAci3sAncE1VUPl9L5ihRhdCoHJjJWB/33222324c600f45c3cfb27a70e14cca7_img.jpg – aafat Oct 14 '16 at 05:09
  • https://parsefiles.back4app.com/PSzewrOeJEAci3sAncE1VUPl9L5ihRhdCoHJjJWB/33222324c600f45c3cfb27a70e14cca7_img.jpg This url hit on browser , i can access on browser but not in app – aafat Oct 14 '16 at 05:20
  • url2 not nil but data is nil – aafat Oct 14 '16 at 05:20
  • And is `data` in `NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://google.com"]];` nil? My guess: Do you have logs in Console that says that App Transport Security is blocking it? See there: http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9 – Larme Oct 14 '16 at 08:08
  • I had already apply this. – aafat Oct 14 '16 at 09:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/125706/discussion-between-vinod-kumar-and-larme). – aafat Oct 14 '16 at 13:30

1 Answers1

0

at Docs from Parse Server have a example to upload files, it's the code below:

NSData *imageData = UIImagePNGRepresentation(image);
PFFile *imageFile = [PFFile fileWithName:@"image.png" data:imageData];

PFObject *userPhoto = [PFObject objectWithClassName:@"UserPhoto"];
userPhoto[@"imageName"] = @"My trip to Hawaii!";
userPhoto[@"imageFile"] = imageFile;
[userPhoto saveInBackground];

Click here to read more: http://docs.parseplatform.org/ios/guide/#files

Other point to check, is the version that you're using, sometimes is related with some bug: https://github.com/parse-community/Parse-SDK-iOS-OSX/releases

nataliec
  • 502
  • 4
  • 14