1

I am using this code below for download file:

- (void)downloadFileContentWithService:(GTLServiceDrive *)service
                                  file:(GTLDriveFile *)file
                       completionBlock:(void (^)(NSData *, NSError *))completionBlock {

    if (file.downloadUrl != nil)
    {
        GTMHTTPFetcher *fetcher =
        [service.fetcherService fetcherWithURLString:file.downloadUrl];

        [fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error) {
            if (error == nil) {
                // Success.
                completionBlock(data, nil);
            } else {
                NSLog(@"An error occurred: %@", error);
                completionBlock(nil, error);
            }
        }];
    } else {
        completionBlock(nil,
                        [NSError errorWithDomain:NSURLErrorDomain
                                            code:NSURLErrorBadURL
                                        userInfo:nil]);
   }

Seems everything goes well and after some time I retrieve my file from the server. But the problem that the file size is About 250 MB.

My question is will app crash on the device if the file size is too big. Do we need to make some restriction or something like this. I have downloaded pdf file.

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277

1 Answers1

0

The app may crash since it's increasing memory quite fast during downloading into the memory. You can download directly to disk to avoid this. Seems like you can use NSFileHandle *downloadFileHandle; property of GTMHTTPFetcher for this purpose.

Toby Speight
  • 27,591
  • 48
  • 66
  • 103