Maheep
Maheep

Reputation: 133

how can I post large video on facebook sdk in iOS?

I am using facebook sdk for uploading videos, but I am not able to upload more than 60MB video on facebook. I tried a lot using NSInputStream also for sending data and all :-

 NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"mov"];
    NSData *videoData = [NSData dataWithContentsOfFile:filePath];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   videoData, @"video.mov",
                                   @"video/quicktime", @"contentType",
                                   @"Video Test Title", @"title",
                                   @"Video Test Description", @"description",
                                   nil];

    FBRequest *request = [FBRequest requestWithGraphPath:@"me/videos" parameters:params HTTPMethod:@"POST"];

    [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        NSLog(@"result: %@, error: %@", result, error);
    }];

Upvotes: 0

Views: 621

Answers (1)

Haentz
Haentz

Reputation: 417

Use dataWithContentsOfFile:options instead. Doesn't try to load all the data into memory, which may make your app getting closed by iOS:

NSData *videoData = [NSData dataWithContentsOfFile:video.localURL options:NSDataReadingMappedAlways error:&error];

Upvotes: 4

Related Questions