I use AFNetworking2.0 upload image, code like:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; [manager.requestSerializer setValue:PARSE_APPLICATION_ID forHTTPHeaderField:@"X-Parse-Application-Id"]; [manager.requestSerializer setValue:PARSE_REST_API_KEY forHTTPHeaderField:@"X-Parse-REST-API-Key"]; [manager.requestSerializer setValue:@"image/jpeg" forHTTPHeaderField:@"Content-Type"]; UIImage *image = [UIImage imageNamed:@"resource.bundle/1.jpg"]; NSData *imageData = UIImageJPEGRepresentation(image, 0.5); [manager POST:@"https://api.parse.com/1/files/kingiol.jpg" parameters:nil constructingBodyWithBlock:^(id formData) { [formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"]; } success:^(NSURLSessionDataTask *task, id responseObject) { NSLog(@"success:%@", responseObject); } failure:^(NSURLSessionDataTask *task, NSError *error) { NSLog(@"Error:%@", error); }];
run this and log success block, and i get the upload response:
success:{ name = "84cff2e0-605c-44de-909f-655379884b67-kingiol.jpg"; url = "http://files.parse.com/5a56e6bf-a4b5-4155-9bf3-238550da126b/84cff2e0-605c-44de-909f-655379884b67-kingiol.jpg"; }
but, when i copy the url, then open with chrome, the image is a invalidate image.
Please help