[SalesForce] How to download VersionData from ContentVersion when ContentSize is large

I'm presently using the mobile SDK with native iOS to download VersionData of content objects thus:

SFRestRequest *request = [[SFRestRequest alloc] init];

request.endpoint = @"services/data/v28.0/sobjects/ContentVersion/";
request.method = SFRestMethodGET;
request.path = [NSString stringWithFormat:@"%@/VersionData",contentVersionId];
request.parseResponse = NO;

[request setAccessibilityLabel:[[NSString alloc] initWithFormat:@"%d", roReadDoc]];

[[SFRestAPI sharedInstance] send:request delegate:_delegate];

This works well on LTE with PDFs of reasonable size (a few MB). However with larger MP4s, I seem to encounter timeout issues.

Is there a better way to download VersionData ie. chunked or streamed, using the API?

Another issue I have is simply that the MP4 will not play in either a UIWebView or MPMoviePlayerController. I have read the following links, which seem to describe my issue, but haven't found an answer yet as to why MP4s from Salesforce seem to be in the incorrect format, or otherwise incompatible. Any idea? Thanks!

Video hosted on Content Documents

View MP4 files on iPad

Edit added: after further investigation it appears to me that a legacy app we are using seems to get this working using an http call in the format

[NAME].force.com/sfc/servlet.shepherd/version/download/[CONTENTVERSIONID]

Best Answer

On VersionData: are you not attempting to download the full document with this request? I don't think this is what SFRestRequest is intended for. Given that you do not necessarily know in advance the size of the document, I think you'd be much better served by streaming directly to disk rather than trying to load the entire document in memory.

On media playback: Have you set the allowsInlineMediaPlayback (default NO) and mediaPlaybackRequiresUserAction (default YES) properties in your UIWebView?

Related Topic