How do we partially load files in chunks from a remote server.

I've been building a finder extension for managing a bunch of videos in a remote server. When I try to click on a video file that is dataless it seems to always trigger fetchContents(for:version:request:completionHandler:).

I have implemented fetchPartialContents(for:version:request:minimalRange:aligningTo:options:completionHandler:) but i haven't been able to trigger this method no matter how large the size of the file is. What are the conditions that i have to meet to trigger this function so i could stream the video data in chunks ?

Answered by Engineer in 758808022

Today, opening the file in Finder will always trigger a full download.

Reading a non-downloaded file outside of any FileCoordination accessor blocks should trigger the fetchPartialContents codepath.

For instance, in C, open a file descriptor with open (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/open.2.html).

Then, read the file descriptor (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/read.2.html#//apple_ref/doc/man/2/read).

You may also be able to trigger the behavior by calling +[NSData dataWithContentsOfFile:options:error:] (https://developer.apple.com/documentation/foundation/nsdata/1547244-datawithcontentsoffile)

Accepted Answer

Today, opening the file in Finder will always trigger a full download.

Reading a non-downloaded file outside of any FileCoordination accessor blocks should trigger the fetchPartialContents codepath.

For instance, in C, open a file descriptor with open (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/open.2.html).

Then, read the file descriptor (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/read.2.html#//apple_ref/doc/man/2/read).

You may also be able to trigger the behavior by calling +[NSData dataWithContentsOfFile:options:error:] (https://developer.apple.com/documentation/foundation/nsdata/1547244-datawithcontentsoffile)

How do we partially load files in chunks from a remote server.
 
 
Q