alok srivastava alok srivastava - 1 month ago 9
Objective-C Question

Video uploading on Google drive via IOS application

I just want to upload video on google drive, till now i able to download the content of text file and also the list of all text file by using DrEdit for Objective-C / iOS sample code.
It also gave a example of image uploading but this is also not helpful for me. So could you please guys share your idea or link or code snippet regarding this, will be appreciable. thanks in advance

Answer

just follow this link this is for uploading image.

i just edit the method

  • (void)uploadPhoto:(UIImage*)image to -(void)uploadVideo: image upload sample

      -(void)uploadVideo{
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"'Quickstart Uploaded File ('EEEE MMMM d, YYYY h:mm a, zzz')"];
    
     GTLDriveFile *file = [GTLDriveFile object];
      file.title = [dateFormat stringFromDate:[NSDate date]];
      file.descriptionProperty = @"Uploaded from the Google Drive iOS Quickstart";
      file.mimeType = @"video/quicktime";
      NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Test" ofType:@"Mov"];
    
      NSError *error = nil;
       NSData *data = [NSData dataWithContentsOfFile:filePath options:nil error:&error];
    // NSData *data = UIImagePNGRepresentation((UIImage *)image);
       GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:data MIMEType:file.mimeType];
        GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:file
                                                   uploadParameters:uploadParameters];
    
      UIAlertView *waitIndicator = [self showWaitIndicator:@"Uploading to Google Drive"];
    
       [self.driveService executeQuery:query
              completionHandler:^(GTLServiceTicket *ticket,
                                  GTLDriveFile *insertedFile, NSError *error) {
                  [waitIndicator dismissWithClickedButtonIndex:0 animated:YES];
                  if (error == nil)
                  {
                      NSLog(@"File ID: %@", insertedFile.identifier);
                      [self showAlert:@"Google Drive" message:@"File saved!"];
                  }
                  else
                  {
                      NSLog(@"An error occurred: %@", error);
                      [self showAlert:@"Google Drive" message:@"Sorry, an error occurred!"];
                  }
              }];
    
    
    }
    
Comments