Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 893567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:14:38+00:00 2026-05-15T14:14:38+00:00

I am working on an app which will upload videos to a Facebook users

  • 0

I am working on an app which will upload videos to a Facebook users wall, however I have not had much success. I present an extended permissions dialog window, and then use the face.video.upload method call. In the debugger, it seems like each parameter is set correctly, however the ext permission dialog never completely displays, and the video file never uploads.

The video file is stored in the app’s documents directory (record and playback work fine) but the upload is broken. I have the video.upload parameters in the dialogDidSucceed: method, and I have modified the FBRequest.m generatePostBody: method to accept video files.

Any help would be tremendous, as I have been banging my head against the wall on this one.
Thanks in advance.

Here is the view controller code:

-(IBAction)loginToFacebook
{
  session = [[FBSession sessionForApplication:kAPIKey secret:kAPISecret delegate:self] retain];

  FBLoginDialog *loginDialog = [[[FBLoginDialog alloc] initWithSession:session] autorelease];

  [loginDialog show];
}

-(IBAction)askPermission
{
  //---------------ask permission---------------------/
  FBPermissionDialog *permDialog = [[[FBPermissionDialog alloc]init]autorelease];

  permDialog.delegate = self;

  permDialog.permission = @"video_upload";

  [permDialog show];
}   


-(void)dialogDidSucceed:(FBPermissionDialog *)dialog
{

  //---------------video file path--------------------/
  NSString *path = [NSString stringWithFormat:@"%@/Documents/%@.mov", NSHomeDirectory(), aSelectedQuote.quoteID];

  //---------------video data converter---------------/

  NSData *videoData = [NSData dataWithContentsOfFile:path];

  videoFileName = [NSString stringWithUTF8String:[videoData bytes]];

  //---------------dict for FB upload-----------------/
  NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];

  [args setObject:videoFileName forKey:@"video"];
  [args setObject:aSelectedQuote.quoteTitle forKey:@"title"];

  //---------------FBRequest--------------------------/
  FBRequest *uploadVideoRequest = [FBRequest requestWithDelegate:self];

  [uploadVideoRequest call:@"facebook.video.upload" params:args dataParam:videoData];

  //[uploadVideoRequest call:@"facebook.video.upload" params:args];


  NSLog(@"Upload video button pushed.");

}

-(void)dialogDidCancel:(FBDialog *)dialog
{
  NSLog(@"user canceled request");
}



-(void)session:(FBSession *)session didLogin:(FBUID)uid
{
  NSLog(@"user with id %lld logged in.",uid);

  NSString *fql = [NSString stringWithFormat:@"select uid, name from user where uid == %lld", session.uid];

  NSDictionary *params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];

  [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];

}

/*
  -(void)sessionDidLogout:(FBSession *)session
  {
  }
*/


-(void)request:(FBRequest *)request didLoad:(id)result
{
  if ([result isKindOfClass:[NSArray class]])
    {
      NSArray *users = result;
      NSDictionary *user = [users objectAtIndex:0];
      NSString *name = [user objectForKey:@"name"];

      NSLog(@"FBRequest didLoad: - logged in as %@",name);
    }
}

-(void)dialog:(FBDialog *)dialog didFailWithError:(NSError *)error
{
  NSLog(@"Error (%d) %@", [error code], [error localizedDescription]);
}

Here is the FBRequest.m code:

- (NSMutableData*)generatePostBody {
  NSMutableData* body = [NSMutableData data];
  NSString* endLine = [NSString stringWithFormat:@"\r\n--%@\r\n", kStringBoundary];

  [self utfAppendBody:body data:[NSString stringWithFormat:@"--%@\r\n", kStringBoundary]];

  for (id key in [_params keyEnumerator]) {
    [self utfAppendBody:body
      data:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key]];
    [self utfAppendBody:body data:[_params valueForKey:key]];
    [self utfAppendBody:body data:endLine];
  }

  if (_dataParam != nil) {
    if ([_dataParam isKindOfClass:[UIImage class]]) {
      NSData* imageData = UIImagePNGRepresentation((UIImage*)_dataParam);
      [self utfAppendBody:body
        data:[NSString stringWithFormat:@"Content-Disposition: form-data; filename=\"photo\"\r\n"]];
      [self utfAppendBody:body
        data:[NSString stringWithString:@"Content-Type: image/png\r\n\r\n"]];
      [body appendData:imageData];
    } else {
      NSAssert([_dataParam isKindOfClass:[NSData class]], @"dataParam must be a UIImage or NSData");
      /*           
               [self utfAppendBody:body
               data:[NSString stringWithFormat:@"Content-Disposition: form-data; filename=\"data\"\r\n"]];
               [self utfAppendBody:body
               data:[NSString stringWithString:@"Content-Type: content/unknown\r\n\r\n"]];
               [body appendData:(NSData*)_dataParam];
      */
      if ([_method isEqualToString:@"facebook.video.upload"]) {
    [self utfAppendBody:body
          data:[NSString stringWithFormat:@"Content-Disposition: form-data; filename=\"data.mov\"\r\n"]];
    [self utfAppendBody:body
          data:[NSString stringWithString:@"Content-Type: video/quicktime\r\n\r\n"]];
      }
      else {
    [self utfAppendBody:body
          data:[NSString stringWithFormat:@"Content-Disposition: form-data; filename=\"data\"\r\n"]];
    [self utfAppendBody:body
          data:[NSString stringWithString:@"Content-Type: content/unknown\r\n\r\n"]];
      }

    }
    [self utfAppendBody:body data:endLine];
  }

  FBLOG2(@"Sending %s", [body bytes]);
  return body;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:14:38+00:00Added an answer on May 15, 2026 at 2:14 pm

    You’re setting videoFileName to the raw bytes of the videofile:

    videoFileName = [NSString stringWithUTF8String:[videoData bytes]];
    ....
    [args setObject:videoFileName forKey:@"video"];
    

    I think you meant:

    videoFileName = [path lastPathComponent];
    

    I hope this fixes your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a paying app which will have LVL enabled, which means
I am working on an iPad app (which will not be submitted to the
I'm working on an iOS app which will need a server backend for users
I have an MFC app which I have been working on for a few
I am trying to make an Android app which will pull uploaded videos from
I am working on an app which will be full-screen, but will utilize some
I'm planning on creating an app which will utilise Phonegap, however the app is
I'm currently working on a app for a podcast (katg.com) which will let you
I am working on a django project which will contain several apps. Each app
I'm working on a live photo stream app. Essentially, users will be uploading photos

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.