适用于iOS的Google Drive API下载文件

编程入门 行业动态 更新时间:2024-10-20 03:38:30
本文介绍了适用于iOS的Google Drive API下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用以下代码下载文件:

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下载文件

本文发布于:2023-11-28 10:04:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641957.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   文件   iOS   Google   Drive

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!