我正在使用以下代码下载文件:
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]); }似乎一切正常,过了一段时间,我从服务器上检索了我的文件.但是文件大小约为250 MB的问题.
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.
我的问题是,如果文件太大,应用程序将在设备上崩溃.我们需要做一些限制或类似的事情吗?我已经下载了pdf文件.
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.
推荐答案该应用程序可能会崩溃,因为它在下载到内存期间非常快地增加了内存.您可以直接下载到磁盘上以避免这种情况.似乎您可以使用NSFileHandle * downloadFileHandle; 属性="nofollow"> GTMHTTPFetcher .
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.
更多推荐
适用于iOS的Google Drive API下载文件
发布评论