Question

Hi I am downloading a media file of 3 MB from Google Drive. The file finish downloading after 82 kb.. it is not downloading completely. I have checked with small file.. but the download size remains constant for any size of file.. that is 82 kb..

I am trying GTMHTTPFetcher to download..but getting error

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
GTLDriveFile *file;
NSString *downloadedString = file.downloadUrl; // file is GTLDriveFile

NSLog(@"%@",file.downloadUrl);

GTMHTTPFetcher *fetcher = [self.driveService.fetcherService  fetcherWithURLString:downloadedString];

[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error)
{
    if (error == nil)
    {
        if(data != nil)
        {

            GTLDriveFile *file = [driveFiles objectAtIndex:indexPath.row];

            filename=file.title;

            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            filename = [[paths objectAtIndex:0]stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",fileNames]];
            NSData* Data = [[NSData alloc]initWithContentsOfURL:targetURL];
            [Data writeToFile:filename atomically:YES];
            NSLog(@"my path:%@",filename);


        }
    }
    else
    {
        NSLog(@"Error - %@", error.description);
    }
 }];


// from the above code error is **Domain=com.google.GTMHTTPFetcher Code=-1 "The operation couldn’t be completed. (com.google.GTMHTTPFetcher error -1.)"**
Était-ce utile?

La solution

I don't have a solution, but I have a diagnosis, and the next step. If multiple files, some long, some short, are fetching 82KB, then double check that you are fetching the correct URL.

It looks like, when the user chooses a filename you aren't fetching the correct URL, but something returning 82KB of data, like the directory listing.

You can check by running the DrEdit sample app from https://developers.google.com/drive/examples/objectivec and by turning on GMHTTPFetcher logging, (GMHTTPFetcher is a wrapper for NSURLConnection) http://code.google.com/p/gtm-http-fetcher/wiki/GTMHTTPFetcherIntroduction#HTTP_Logging

Autres conseils

i think u r giving time out interval thats why its finishes loading at fix time.

The method downloadFormatSelected: in the [DriveSample sample app][1] shows how to do an authenticated file download.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top