I always get "(#324) Requires upload file" when I post an image to facebook, there are many people asked the question with the same error, most of them are using php sdk, seems they solved the problem by set fileUpload to true ($facebook->setFileUploadSupport(true);), for example: http://endorkins.com/2010/12/28/facebook-graph-api-upload-photos-requires-upload-file/, Exception when uploading photo with Facebook Graph API
But I am using graph api directly in iOS, I can't find where to set this flag, I tried to set it when create the album and when upload the image, but it didn't work.
Facebook graph API reference (http://developers.facebook.com/docs/reference/api/album/) said can_upload must be true for an album to allow upload photos to the album, I checked the album that I tried to upload the image and it is true.
I also have permission of user_photos, friends_photos, publish_stream, publish_actions.
Below is my code to post the image, I have spent a lot of time on this but can't fix it, plz help me! any help is appreciated.
NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/"];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:url];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:token forKey:@"access_token"];
[params setObject:@"the message" forKey:@"message"];
NSData *imgData = UIImageJPEGRepresentation(self.img, 1.0);
[params setObject:imgData forKey:@"source"];
NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:[NSString stringWithFormat:@"%@/photos", albumId] parameters:params];
[request setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
// [request setValue:[NSString stringWithFormat:@"%d", imgData.length] forHTTPHeaderField:@"Content-Length"];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", error);
NSLog(@"%@", operation.responseString);
}];
[operation start];