简体   繁体   中英

Multipart Upload using Google Drive iOS sdk

How can I sync very big files like Video files to Google drive using GTLServiceDrive service? I know that sync is possible using queryForFilesInsertWithObject:uploadParameters: method. But here I pass data as a parameter of GTLUploadParameters object. But if I am uploading big files, I cannot hold the whole object in memory. Does Google drive ios sdk supports multi-part upload? If Yes, can someone point me how to do it.

Thanks in advance!

Instead of reading the file contents into a NSData instance you can configure your upload parameters to use a NSFileHandle to the file you want to upload. The SDK will upload the file in chunks.

NSString *filePath = @"/path/to/file";
NSString *mimeType = @"text/plain";
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:filePath];
GTLUploadParameter *uploadParameters = [GTLUploadParameters uploadParametersWithFileHandle:file
                                                                             MIMEType:mimeType];

Official documentation here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM