简体   繁体   中英

Google Drive SDK iOS - Upload LARGE video ALAssetRepresentation using NSData (not NSFileHandle)?

The example ...

https://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Uploading_Files

... uses NSFileHandle ...

NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:path];
if (fileHandle) {
  NSString *mimeType = @"image/jpeg";
  GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithFileHandle:fileHandle
                                                                                     MIMEType:mimeType];

... which means that you would need to (re)persist the ALAssetRepresentation to disk to be able to get a NSFileHandle, instead of just using ALAssetRepresentation getBytes:, and using NSData ...

GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:uploadData
                                                                             MIMEType:fileObj.mimeType];

... is there a way to stream the ALAssetRepresentation NSData to the GTLServiceDrive query?

Trying to ALAssetRepresentation getBytes: for a large video into memory causes a crash.

Also, re(persisting) the ALAssetRepresentation to disk seems like waste - extra processing time & space (that may not exist).

Surely there is a nice way to do this with the Google Drive iOS SDK & direct ALAssetRepresentation streamed NSData?

The DriveSDK only works with NSFileHandle, and from what I can tell there is no way to convert between an ALAssetRepresentation to a NSFileHandle except persisting to disk. See this related Stack Overflow question .

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